I need a bash line to check if java version currently installed is Oracle's or OpenJDK.
A one-liner by parsing the output of the java -version
command:
java -version
java Oracle output:
java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
java OpenJDK Output:
java version "1.7.0_91" OpenJDK Runtime Environment (amzn-2.6.2.2.63.amzn1-x86_64 u91-b00) OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
Open command prompt and enter “java –version”. If installed version number is displayed.
This depends a bit from your package system ... if the java command works, you can type readlink -f $(which java) to find the location of the java command.
To check which version of Java is installed, follow this procedure: -Open a Linux command prompt. -Enter the command java -version. -If Java version is installed on your system, you see a Java installed response.
if [[ $(java -version 2>&1) == *"OpenJDK"* ]]; then echo ok; else echo 'not ok'; fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With