8340133: Add concise usage message to the java executable

Reviewed-by: jpai, alanb, ihse, rriggs
This commit is contained in:
Jan Lahoda 2024-12-02 11:21:13 +00:00
parent 0b0f83c01e
commit c7be41ee0c
3 changed files with 97 additions and 54 deletions

View file

@ -589,6 +589,15 @@ public final class LauncherHelper {
}
}
/**
* Prints the short usage text to the desired output stream.
*/
static void printConciseUsageMessage(boolean printToStderr) {
initOutput(printToStderr);
ostream.println(getLocalizedMessage("java.launcher.opt.concise.header",
File.pathSeparator));
}
static void initOutput(boolean printToStderr) {
ostream = (printToStderr) ? System.err : System.out;
}

View file

@ -26,14 +26,14 @@
# Translators please note do not translate the options themselves
java.launcher.opt.header = Usage: {0} [options] <mainclass> [args...]\n\
\ (to execute a class)\n\
\ or {0} [options] -jar <jarfile> [args...]\n\
\ or {0} [options] -jar <jarfile>.jar [args...]\n\
\ (to execute a jar file)\n\
\ or {0} [options] -m <module>[/<mainclass>] [args...]\n\
\ {0} [options] --module <module>[/<mainclass>] [args...]\n\
\ (to execute the main class in a module)\n\
\ or {0} [options] <sourcefile> [args]\n\
\ or {0} [options] <sourcefile>.java [args]\n\
\ (to execute a source-file program)\n\n\
\ Arguments following the main class, source file, -jar <jarfile>,\n\
\ Arguments following the main class, source file, -jar <jarfile>.jar,\n\
\ -m or --module <module>/<mainclass> are passed as the arguments to\n\
\ main class.\n\n\
\ where options include:\n\n
@ -46,15 +46,15 @@ java.launcher.opt.footer = \
\ -cp <class search path of directories and zip/jar files>\n\
\ -classpath <class search path of directories and zip/jar files>\n\
\ --class-path <class search path of directories and zip/jar files>\n\
\ A {0} separated list of directories, JAR archives,\n\
\ A "{0}"-separated list of directories, JAR archives,\n\
\ and ZIP archives to search for class files.\n\
\ -p <module path>\n\
\ --module-path <module path>...\n\
\ A {0} separated list of elements, each element is a file path\n\
\ A "{0}"-separated list of elements, each element is a file path\n\
\ to a module or a directory containing modules. Each module is either\n\
\ a modular JAR or an exploded-module directory.\n\
\ --upgrade-module-path <module path>...\n\
\ A {0} separated list of elements, each element is a file path\n\
\ A "{0}"-separated list of elements, each element is a file path\n\
\ to a module or a directory containing modules to replace\n\
\ upgradeable modules in the runtime image. Each module is either\n\
\ a modular JAR or an exploded-module directory.\n\
@ -232,6 +232,23 @@ The following options are macOS specific:\n\
\ -Xdock:icon=<path to icon file>\n\
\ override default icon displayed in dock\n\n
# Translators please note do not translate the options themselves
java.launcher.opt.concise.header = Usage: java [java options...] <application> [application arguments...]\n\n\
\Where <application> is one of:\n\
\ <mainclass> to execute the main method of a compiled main class\n\
\ -jar <jarfile>.jar to execute the main class of a JAR archive\n\
\ -m <module>[/<mainclass>] to execute the main class of a module\n\
\ <sourcefile>.java to compile and execute a source-file program\n\n\
\Where key java options include:\n\
\ --class-path <class path>\n\
\ where <class path> is a list of directories and JAR archives to search for class files, separated by "{0}"\n\
\ --module-path <module path>\n\
\ where <module path> is a list of directories and JAR archives to search for modules, separated by "{0}"\n\
\ -version\n\
\ to print product version to the error stream and exit\n\n\
\For additional help on usage: java --help\n\
\For an interactive Java environment: jshell
java.launcher.bad.option=\
\n\
Unrecognized showSettings option: {0}\n\