Is there a way to detect the installed java on various different Linux distributions? With Windows you could use the JAVA_HOME or the registry for that, but Linux? Can it be also detected if this is JDK, JRE, 32 or 64 bit?
REPHRASE: If I need 64-bit JDK on Linux, how do I programatically check that it is present and inform the user that he has some other java instead?
You can always use java -version
.
This works on all platforms, but make sure that Java is included in the system PATH variable.
No unified way. You can use JAVA_HOME env. variable but it is not defined on all machines.
But there is a "common" way like ls /usr/java/*/bin/java | tail -1
.
This should give in most cases you the latest version.
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