How to know the JVM path in a Linux system?

I want to copy some files in the subdirectories of the JVM path , java is already installed. How to know the JVM's path ?


Solution 1:

locate java

This will give you the location of java installation in your system.

Most probably it would be:

/usr/lib/java/

Solution 2:

Check your $JAVA_HOME environment variable from a terminal:

echo $JAVA_HOME

Solution 3:

In linux you can use the whereis and which shell commands.

which java
whereis java

which will give you the jre path in /usr/bin folder which will be /usr/bin/java most probably. This is not the actual jre file but it's just a symbolic link to the actual jre file which is located else where. To know the actual jre path you will have to write

readlink -f /usr/bin/java

or whatever was the path of jre returned by which/whereis command.