RFR: 8340133: Add concise usage message to the java executable [v9]
Jan Lahoda
jlahoda at openjdk.org
Mon Nov 18 16:00:52 UTC 2024
On Mon, 18 Nov 2024 15:50:49 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> Currently, running `java` without any parameters will lead to an output that is a full `--help`, which is over 100 lines (on my computer at least), and it feels overwhelming. And many people might actually want to run JShell/REPL, not the `java` executable, but it is difficult find out about JShell.
>>
>> The proposal herein is to print a much shorter help, together with a pointer to JShell, when the executable does not know what to do. I.e. there is nothing specified to start, and no option like `--help` is specified. In particular, on my machine, it prints:
>>
>> openjdk version "24-internal" 2025-03-18
>>
>> Usage: java [java options...] <application> [application arguments...]
>>
>> Where <application> is one of:
>> <mainclass> to execute the main method of a compiled main class
>> -jar <jarfile>.jar to execute the main class of a JAR archive
>> -m <module>[/<mainclass>] to execute the main class of a module
>> <sourcefile>.java to compile and execute a source-file program
>>
>> Where key java options include:
>> --class-path <class path>
>> where <class path> is a list of directories and JAR archives to search for class files, separated by ":"
>> --module-path <module path>
>> where <module path> is a list of directories and JAR archives to search for modules, separated by ":"
>>
>> For additional help on usage: java --help
>> For an interactive Java environment: jshell
>>
>>
>> Hopefully, this may be easier both for people trying to run something, and for people that are really looking for JShell.
>>
>> What do you think?
>>
>> Thanks!
>
> Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 14 commits:
>
> - Merge branch 'master' into JDK-8340133-2
> - - suffixing <jarfile> and <sourcefile> with .jar and .java in both the concise and full help.
> - using a stderr version instead of the stdout version.
> - Reflecting review feedback:
> - using "conciseVersionString" intead of "shortVersionString"
> - using <jarfile>.jar <jarfile>
> - Merge branch 'master' into JDK-8340133-2
> - Using correct pplaceholders.
> - Adjusting text as suggested.
> - Cleaning up the concise message:
> - using 2 spaces instead of 4,
> - rewording the "for more use --help" part of the message as suggested to avoid the word "launcher".
> - Using lowercase for the keys in the help, using 'source-file' program instead of 'single-file' program.
> - Using an enum instead of booleans, as suggested.
> - Adjusting the concise help as suggested: 'using main class of a JAR archive' and '<JarFile>.jar'/'<SourceFile>.java'
> - ... and 4 more: https://git.openjdk.org/jdk/compare/dfddbcaa...439fa40f
I am a bit confused about what's the recommendation about the version, as there seem to be conflicting comments on that . I replaced the version with the stderr version here:
https://github.com/openjdk/jdk/pull/21411/commits/d4860961e2ff7e6218a16a2ed3990a0deba3ae1a
I can drop the version altogether if/as desired.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21411#issuecomment-2483456980
More information about the core-libs-dev
mailing list