Sep
2

Making “java -v”, “java –version”, and “java version” Work

By Rob Warner  //  Java  //  No Comments

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.

Leave a comment

About

I'm Rob Warner, and I'm a software developer. I live in Jacksonville, Florida, and work for Availity, LLC. The postings on this site are my own and do not necessarily reflect the views of Availity.