< 1 minutes read

Get java version in linux using a one liner

Command: java -version


openjdk version "1.8.0_192"
OpenJDK Runtime Environment (Zulu (build 1.8.0_192-b01)
OpenJDK 64-Bit Server VM (Zulu (build 25.192-b01, mixed mode)

So, here how do I fetch 1.8.0_192 ?

Use below command, this redirects the stderr to stdout and then filters the java version number.

java -version 2>&1|awk -F\" '/version/ {print $2}'


I am a Fullstack developer and Consultant with an experience of 9+ years in the industry. I mainly work on Java, React, Javascript, NodeJs, Elasticsearch and Botpress.


Leave a Reply

Avatar placeholder

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.