Shell How to know which version of the Java executable is being ran...

Hello again,

I am in need to knowing the "real" Java executable being run by the the /usr/local/bin/java script.

Here is a little background...

When you run which java, I get...

Bash:
root@localhost:~ # which java
/usr/local/bin/java
root@localhost:~ #

This tells me that when I run java, I will actually be running /usr/local/bin/java... That is all well and good...

When I run a Java application using this JVM and look at ps, I see this...

Bash:
root     25770   0.0  1.2 2119480 396972  -  I    09:33      0:16.12 /usr/local/openjdk8/jre/bin/java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=32765 -Xms512M -Xmx512M -Dlog4j.configurationFile=file:///usr/local/...

This tells me that when I run java, which actually runs /usr/local/bin/java, it then actually runs /usr/local/openjdk8/jre/bin/java...

That is what I would like to know... Is there a command or something I can run via a script to tell me directly what /usr/local/bin/java is going to run?

Hopefully that all makes sense...

Thanks,
 
Is there a command or something I can run via a script to tell me directly what /usr/local/bin/java is going to run?
Code:
% env JAVA_VERSION=8 java -version
openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)
% env JAVA_VERSION=11 java -version
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-1)
OpenJDK 64-Bit Server VM (build 11.0.16+8-1, mixed mode)
% cat /usr/local/etc/javavms
/usr/local/openjdk11/bin/java
/usr/local/openjdk8/bin/java
# First one on the list is the 'default':
% java -version
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-1)
OpenJDK 64-Bit Server VM (build 11.0.16+8-1, mixed mode)
 
Back
Top