A version of java is installed on my Linux machine. When i try this:

root@test$: javac -version

It given the result as:

javac jdk1.7.0_80.

Now my problem is i don't know where that(1.7.0_80) java folder is. I have a folder named "java-7-oracle" in usr/lib/jvm. I am suspecting that it would be the folder for the installed version of java.

Now I have a java folder and I want to know which version of java it is?


3 Answers 3


I think you can track all this by checking to where your java binaries linked to.

       #which javac
       #ls -ln /usr/bin/java
           lrwxrwxrwx. 1 0 0 22 Nov 27 04:54 /usr/bin/java -> /etc/alternatives/java
       #ls -ln /usr/bin/javac
            lrwxrwxrwx. 1 0 0 23 Nov 27 04:54 /usr/bin/javac -> /etc/alternatives/javac
       # ls -ln /usr/bin/javadoc
            lrwxrwxrwx. 1 0 0 25 Nov 27 04:54 /usr/bin/javadoc -> /etc/alternatives/javadoc

and finally:

#ls -ld /etc/alternatives/java
lrwxrwxrwx. 1 root root 46 Nov 27 04:54 /etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

therefore , my java installation is:


I suppose you can track any binary like this.


Finding out which binary is executed when you type only the name is done using which, and using readlink you can condense the process to a single line.

readlink -e $(which java)

readlink -e prints the value of a symbolic link or canonical file name, and the -e ensures it follows every component recursively.

tony@trinity:~$ readlink -e $(which java)

note: I don't have javac installed on the machine I tested this on, so just used java, but the above will work work for any binary.

You also appear to be asking to find out which version of java is in a specific folder? For that you just do this,

/full/path/java -version

which prevents Linux from search the path and finding the java binary directly. In your case,

/usr/lib/jvm/java-7-oracle/javac -version

On Debian and its derivatives You could use:

update-alternatives --config java


update-alternatives --list java

With --config option you can set required java from list of alternatives.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .