Configure Java environment on Linux

After installing Java Development Kit or Java Runtime Environment on Linux/Unix, you may still need to do some configuration to get Java ready for running or compiling Java programs. The following instruction will guide you through the process of setting up JDK for software development. JRE can be configured similarly.

JDK is usually installed into /usr/java directory. Create a symbolic link to the installation directory. That way makes it easier to switch between different Java versions that you may have just by redirecting the link to the appropriate target directory.

# ln -s /usr/java/jdk1.5.0 /usr/java/j2se

Create a file in /etc/profile.d directory with content as follows:

export CLASSPATH=.

The file contains various shell commands which set and export necessary environment variables for Java. It assumes Apache Ant and Unicode TrueType fonts have been installed in appropriate directories. Ant is a tool widely used in building and executing Java applications. Shell settings from configuration files in the /etc/profile.d directory are gathered by /ect/profile during login, setting up user environment information for every user.

Assign execute permissions:

# chmod 755

You can verify the availability of Java to users after login by:

# java -version


References & Resources

Install and configure Unicode TrueType fonts in Linux
Configure Java environment on Windows