How to install and configure JDK in Linux
I have read about JDK installation and configuration methods recently. Now I am sending you a simple and correct method for your reference ~~~~~~~~
1. Install JDK
Download JDK directly from sun: The http://java.sun.com/j2se/1.4.2/download.html provides two downloads:
1. RPM in self-extracting file (j2sdk-1_4_2_04-linux-i586.bin, 32.77 MB) This is a self-extracting file, installed on linux as follows:
# Chmod u + x./j2sdk-1_4_2_04-linux-i586.bin
#./J2sdk-1_4_2_04-linux-i586.bin
After entering yes as prompted, jdk is decompressed to The./j2sdk1.4.2 _ 04 directory. In order to be consistent with the JDK installation path in the following 2, we will perform the following operations to establish the installation path under/usr/java and test the file to this path:
# Mkdir/usr/java
# Cp-fr./j2sdk1.4.2 _ 04/usr/java
2. RPM in self-extracting file (j2sdk-1_4_2_04-linux-i586-rpm.bin, 32.77 MB) This is also a self-extracting file, but the extracted file is a j2sdk-1_4_2_04-linux-i586-rpm package, run the rpm command to install it on linux. The installation is as follows:
# Chmod u + x./j2sdk-1_4_2_04-linux-i586-rpm.bin
#./J2sdk-1_4_2_04-linux-i586-rpm.bin
# Rpm-ivh j2sdk-1_4_2_04-linux-i586-rpm
The installation software automatically installs JDK in the/usr/java/j2sdk1.4.2 _ 04 directory.
2. Configure Environment Variables
1. Modify user environment variables
Assume that the java User is kunp. Edit the user's. bashrc file to set environment variables.
# Vi/home/kunp/. bashrc
Add the following to the. bashrc file:
Export JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04
Export CLASSPATH = $ CLASSPATHJAVA_HOME/libJAVA_HOME/jre/lib
Export PATH = $ JAVA_HOME/binJAVA_HOME/jre/binPATH: $ HOMR/bin
2. Modify the environment variables of all users
# Vi/etc/profile
Add:
Export JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04
Export CLASSPATH = $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib
Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH: $ HOMR/bin
Be sure to add $ classpath to the classpath path: Because I didn't add this stuff before, I always reported an error when interpreting and executing the class file.