Three ways to configure Java environment variables in Linux

  

For many beginners, I don't know how to configure Java environment variables, especially in Linux systems. The following small series will introduce you how to configure in Linux. Java environment variables, I hope to help you.

a. Unzip the installation jdk

Enter the directory where the jdk-6u14-linux-i586.bin file is located in the shell terminal,

execute the command. /jdk-6u14-linux-i586.bin At this point, there will be a protocol, and then hit enter, when asked if you agree, enter yes and press Enter. Then a jdk1.6.0_14 directory will be generated in the current directory, you can copy it to any directory.

Two. Environment variables that need to be configured

1. PATH environment variable. The role is to specify the command search path, when the command is executed under the shell, it will look in the path specified by the PATH variable to see if it can find the corresponding command program. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains executable files such as javac/java/javadoc that are often used. After setting the PATH variable, it can be in any directory. Execute tools such as javac/java.

2. CLASSPATH environment variable. The role is to specify the class search path, to use the already written classes, of course, can be found, JVM is to find the class through CLASSPTH. We need to set the dt.jar and tools.jar in the lib subdirectory under the jdk installation directory to the CLASSPATH, of course, the current directory “. ” must also be added to this variable.

3. JAVA_HOME environment variable. It points to the jdk installation directory. Eclipse/NetBeans/Tomcat and other software finds and uses the installed jdk by searching the JAVA_HOME variable.

Three. Three ways to configure environment variables 1. Modify the /etc/profile file

This method is recommended if your computer is only used as a development, because all users' shells have access to these environment variables, possibly Will bring security problems to the system.

· Open /etc/profile

· with a text editor. Add at the end of the profile:

The code is as follows:

export JAVA_HOME=/Usr/share/jdk1.6.0_14

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=. :$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

·Re-login
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved