Today, JDK was installed under Linux, a little problem in the environment variable classpath setting, I have been searching for a long time, I found very little, maybe everyone feel too simple, no need to write, do it, write yourself If you have a brother, you can find something when you have the brothers who have also made the same mistake.
First, install JDK
Download directly from the Sun website: 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 self-extracting file, installed on Linux:
# chmod u x ./j2sdk-1_4_2_04-linux-i586.bin
# ./j2sdk-1_4_2_04-linux-i586.bin
After entering YES by prompt, the JDK is decompressed to ./j2sdk1.4.2_04 directory. To match the JDK installation path below, we do the following, establish the installation path under / usr / java, and take the file to the 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 decompressed file is J2SDK-1_4_2_04-Linux-i586-RPM package, execute RPM The command can be installed on Linux. Installed 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
Installing the software automatically installs the JDK to the /usr/java/j2sdk1.4.2_04 directory.
Second, configure environment variables
1. Modify user environment variables
Assume that users using Java for KUNP, edit the user's .bashrc file for environment variable settings.
# vi /Home/kunp/.bashrc
Add: in the .bashrc file:
export JAVA_HOME = / usr / java / j2sdk1.4.2_04export CLASSPATH = $ CLASSPATH: $ JAVA_HOME / lib: $ JAVA_HOME / jre / libexport PATH = $ JAVA_HOME / bin: $ JAVA_HOME / jre / bin: $ PATH: $ HOMR / bin
2. Modify all users' environment variables
# VI / ETC / Profile
Add:
export JAVA_HOME = / usr / java / j2sdk1.4.2_04export CLASSPATH = $ CLASSPATH: $ JAVA_HOME / lib: $ JAVA_HOME / jre / libexport PATH = $ JAVA_HOME / bin: $ JAVA_HOME / jre / bin: $ PATH: $ HOMR / bin
Be sure to add $ ClassPath in the ClassPath path: I have always reported that when I don't join this stuff, I always report when explaining the execution of the Class file.
Now let's see if Java is completely installed, write a favorite Java file:
Hellodate.java
----------------------------------------- // Hellodate.javaImport java.util. Date;
Public class hellodate {public static void main (string [] args) {system.out.println ("Hello, IT's:"); system.out.println (new date ());}}
------------------------------------------
Compile execution of this file under KUNP users:
# su - kunp
$ JAVA Hellodate.java $ Java HellodateHello, It's: Thu Jun 10 14:21:21 CST 2004
OK, Java environment is built. Start writing your Java program.