java -version simply outputs :
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)Need to find out if I am using the oracle version or the open-jdk version.
12 Answers
You can write a simple bash script to check this out:
- Open any text editor (preferrably vim or emacs).
- create a file named script.sh (or any name with the .sh extension).
paste the following code in it:
#!/bin/bash if [[ $(java -version 2>&1) == *"OpenJDK"* ]]; then echo ok; else echo 'not ok'; fi- save and exit the editor.
- Execute the code using
bash name.sh(The code return ok if you have a openJDK else not ok).
A typical output from running the same command to check the version for an OpenJDK version would be:
$ java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)Sumit Kumar is just checking for this using bash