RFR: 8340133: Add concise usage message to the java executable [v5]

Jan Lahoda jlahoda at openjdk.org
Tue Oct 22 11:06:44 UTC 2024


> 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 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 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>
>     a ":"-separated list of directories and JAR archives to search for class files
>   --module-path <module path>
>     a ":"-separated list of directories and JAR archives to search for modules
> 
> 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 incrementally with one additional commit since the last revision:

  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".

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/21411/files
  - new: https://git.openjdk.org/jdk/pull/21411/files/5d82312f..dc85a167

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21411&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21411&range=03-04

  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/21411.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21411/head:pull/21411

PR: https://git.openjdk.org/jdk/pull/21411


More information about the core-libs-dev mailing list