Draft JEP: Launch Single-File Source-Code Programs

Jaikiran Pai jai.forums2013 at gmail.com
Tue Feb 13 04:19:32 UTC 2018

Hi Jonathan,

The motivation behind this feature, as noted in the motivation section, 
IMO is good - to allow developers getting started with Java to be able 
to try out small utility programs without having to go through multiple 
different tools/commands.

As such, the first part of the JEP which states that the java tool would 
be enhanced to support this feature sounds reasonable. However, the 
additional change/enhancement to support shebang files, IMO, just adds 
more complexities to support, what I think, is a non-existent 
requirement. Complexities/questions like:

- Given that the feature is mostly targeted towards new users, what 
purpose would a shebang serve for such users, if they are on a Windows 
OS. Not starting a OS war, but it still is the most used OS for 
development, which effectively would mean that not many will use this 
shebang feature, IMO.

- What happens when the user moves one step forward in learning Java and 
now wants to use this existing class (which has a shebang) along with 
some other newer class(es) and wants to compile and build the 
application? How would other tools like (javac) react to it? Would those 
tools too now understand the shebang mechanism?

- I'm not an expert on compilers, but AFAIK, Eclipse IDE uses its own 
compiler. Would that mean that these external compilers too will have to 
now understand and support the shebang support?

Personally, except for the proposal to support shebang, the JEP looks good.


On 12/02/18 7:52 PM, Roger Riggs wrote:
> Hi Jonathan,
> It would be  a great convenience to developers to NOT to have two 
> types of java source files.
> Those that can be run directly and those that cannot. According to the 
> JLS, the former can not
> be called java source files, they are something else.
> $.02, Roger
> On 2/10/2018 11:59 AM, Jonathan Gibbons wrote:
>> Volker,
>> I don't see a compelling need to change the JLS to accommodate 
>> "shebang" files. Most Java source files don't need the `#!` line, 
>> including any source file passed to an explicit invocation of the 
>> Java launcher. The line is only needed when the file is set up to be 
>> directly executed by the "shebang" mechanism, in which case the line 
>> can be thought of as a "wrapper" supported by the host system to 
>> enable such use. If the feature is sufficiently popular, it may even 
>> be that editors will recognize and support the use of such lines, in 
>> the same way that some editors recognize and support the manipulation 
>> of javadoc comments, which are also not defined in the JLS (beyond 
>> the basic definition of a comment in JLS 3.7).
>> -- Jon
>> On 2/9/18 2:51 AM, Volker Simonis wrote:
>>> Hi Jonathan,
>>> that's an interesting proposal. It is just unfortunate that a Java
>>> source file starting with "shebang" won't be a legal Java file
>>> according to the Java Language Specification. Or do you plan to change
>>> the JLS to allow (and ignore) "shebang" in the first line?
>>> Thanks,
>>> Volker
>>> On Fri, Feb 9, 2018 at 12:18 AM, Jonathan Gibbons
>>> <jonathan.gibbons at oracle.com> wrote:
>>>> This draft JEP contains a proposal to enhance the java launcher to 
>>>> support
>>>> running a
>>>> program supplied as a single file of Java source code. The program 
>>>> will be
>>>> compiled
>>>> and run, without the need to explicit invoke javac, or to package 
>>>> up a jar
>>>> file.
>>>> For more details, see:
>>>> http://openjdk.java.net/jeps/8192920
>>>> -- Jon

More information about the jdk-dev mailing list