Draft JEP: Launch Single-File Source-Code Programs

Robert Zenz robert.zenz at sibvisions.com
Fri Feb 9 12:30:17 UTC 2018


Yes, I know, I just don't understand why it is in the JEP. As far as I know, we
can already do that:

    //usr/bin/env javac "$0" && java -cp . Main; exit $?

    public final class Main {
        public static final void main(String[] args) {
	    System.out.println("Test");
        }
    }

Which is crude, for sure, but if `java` can determine that it is a source file,
that would shrink to:

    //usr/bin/env java "$0"; exit $?

    public final class Main {
        public static final void main(String[] args) {
            System.out.println("Test");
        }
    }

On 09.02.2018 12:34, Lennart Börjeson wrote:
> The shebang convention is extremely well established in the unix world. It is simply the mechanism linux/unix provides to select the actual processor for a shell script.
> 
> If we would like a "java shell script" to be directly executable by its processor on unix/linux, I'd say java must needs support the shebang. A unix/linux user expects it.
> 
> Best regards,
> 
> /Lennart
> 


More information about the jdk-dev mailing list