RFR: 8340133: Investigate if the java launcher could give hints about JShell
Jan Lahoda
jlahoda at openjdk.org
Tue Oct 8 15:33:32 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` launcher, 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 launcher 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:
$ java
openjdk 24-internal 2025-03-18
Usage: java [options...] <what to execute> [arguments to main method...]
Where <what to execute> is one of:
<MainClass> to execute the main method of a compiled class
-jar <jar-file.jar> to execute the main class in a JAR archive
-m <module>[/<MainClass>] to execute the main class of a module
<SourceFile.java> to compile and execute a single-file program
Where key 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 more details about this launcher: 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!
-------------
Commit messages:
- Cleanup.
- Adjusting/improving the concise help.
- Attempting to make the java launcher message consice, and let it refer to JShell.
Changes: https://git.openjdk.org/jdk/pull/21411/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21411&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8340133
Stats: 54 lines in 6 files changed: 49 ins; 0 del; 5 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 security-dev
mailing list