Where is the JDK on my UNIX or Linux system?
Question ID : 91
Created on 2009-09-02 at 2:04 PM
Author : Veryant Support [email@example.com]
Online URL : http://support.veryant.com/support/phpkb/question.php?ID=91
The JDK is installed in different locations on different UNIX and Linux operating systems according to the OS or Java vendor recommendations. There is no standard installation location for the JDK between UNIX/Linux systems. Historically it has been installed in one of the directories listed below.
You can ask the system administrator to make sure that the latest version of the JDK is installed and tell you where it located.
Administrators and package installer programs will usually create symbolic links so that /usr/bin/javac points to the latest version of the Java compiler installed on the system. For this reason, you may be able to quickly find the installation directory using "which javac" or "type javac" and "ls -l" to follow the symbolic links until they end up at an actual disk file. For example,
$ which javac
If you are manually searching for the JDK on your UNIX/Linux machine, look in the following directories:
$ ls -l /usr/bin/javac
lrwxrwxrwx 1 root root 23 2008-09-18 00:47 /usr/bin/javac -> /etc/alternatives/javac
$ ls -l /etc/alternatives/javac
lrwxrwxrwx 1 root root 33 2008-09-18 00:47 /etc/alternatives/javac -> /usr/lib/jvm/java-6-sun/bin/javac
$ ls -l /usr/lib/jvm/java-6-sun/bin/javac
-rwxr-xr-x 1 root root 47744 2008-03-25 10:01 /usr/lib/jvm/java-6-sun/bin/javac
The rightmost directory name will usually have suffix that indicates the version number and/or platform. There may be a hyphen between the name and version number. The version number may have dots or underscores. For example,
isCOBOL APS provides a shell script $ISCOBOL/bin/iscc which sets ISCOBOL_JDK_ROOT based on the actual location of the "javac" executable that is in the user's PATH. Here is a snippet of code that you could use in your own shell script to find the location of the JDK:
_JAVAC_LOCATION=`type javac | cut -f3 -d' '`
while [ -h "$_JAVAC_LOCATION" ]; do
_LS_OUTPUT=`ls -ld "$_JAVAC_LOCATION"`
_EXPR_OUTPUT=`expr "$_LS_OUTPUT" : '.*-> (.*)$'`
if expr "$_EXPR_OUTPUT" : '/.*' > /dev/null; then
if [ ! -f "$ISCOBOL_JDK_ROOT/lib/tools.jar" ]
echo "ERROR: Could not locate the Java compiler classes (tools.jar)."
echo "Please ensure that ISCOBOL_JDK_ROOT is set correctly"
Back to Original Question