Making "java -v", "java --version", and "java version" Work
To get the version of most CLI tools, you type the tool’s command name followed by one of these:
- -v
- –version
Some CLI tools, like Git, support a “version” subcommand, so you type the tool’s command name followed by “version”.
Java supports none of these.
Instead, you must type:
java -version\
I’m too old to remember that, so I’ve created a bash/zsh function:
https://gist.github.com/hoop33/e02d8ae9113616e2cd60
Now I can type any of the following:
java -v
java –version
java version
java -version\
And they all give me Java version information.
Tags: