support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets
 

Veryant Knowledge Base
Home > All Categories > Java Platform > Where is the JDK on my UNIX or Linux system?
Question Title Where is the JDK on my UNIX or Linux system?
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
/usr/bin/javac
$ 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
If you are manually searching for the JDK on your UNIX/Linux machine, look in the following directories:

/usr/java
/usr/java/jdk
/usr/j2se
/usr/j2sdk
/usr/jdk
/usr/lib/java
/usr/lib/j2se
/usr/lib/j2sdk
/usr/lib/jdk
/usr/lib/jvm/java
/usr/lib/jvm/j2se
/usr/lib/jvm/j2sdk
/usr/lib/jvm/jdk
/usr/local/java
/usr/local/java/jdk
/usr/local/jdk
/opt/java
/opt/j2se
/opt/j2sdk
/opt/jdk

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,

java-6-sun
jdk-1.6.0-sun
jdk1.6.0
jdk-1_5_0_07-linux-i586
j2sdk1_4_2_02

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:
#!/bin/sh

_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
                _JAVAC_LOCATION="$_EXPR_OUTPUT"
        else
                _JAVAC_LOCATION=`dirname "$_JAVAC_LOCATION"`/"$_EXPR_OUTPUT"
        fi
done

_JDK_BINDIR=`dirname $_JAVAC_LOCATION`
ISCOBOL_JDK_ROOT=`dirname $_JDK_BINDIR`

if [ ! -f "$ISCOBOL_JDK_ROOT/lib/tools.jar" ]
then
        echo "ERROR: Could not locate the Java compiler classes (tools.jar)."
        echo "Please ensure that ISCOBOL_JDK_ROOT is set correctly"
        exit 1
fi

echo $ISCOBOL_JDK_ROOT
Authored by: Veryant Support This question has been viewed 106759 times so far.
Click Here to View all the questions in Java Platform category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. Why do I get a warning "major version 51 is newer than 50"?
  2. When I deploy my application do I need to install the Java Runtime Environment (JRE) separately?
  3. What Java tools are available for troubleshooting problems?
Article Information Additional Information
Article Number: 91
Created: 2009-09-02 2:04 PM
Rating: 2 Stars
 
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
 
Search Knowledge Base Search Knowledge Base



  Home  |   About Us   |  Contact  |   Legal   |  Privacy   |  Press
 

© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.