My system is RH9, the full installation is selected, and after the online J2SDK-1_4_2_05-Linux-i586-rpm.bin, after installation
Java -Version
It is found that it is Linux comes with
-------------------------------------------------- ---------------------------------
Java Version "1.3.1"
JDKGCJ 0.2.3 (http://www.arklinux.org/projects/jdkgcj)
GCJ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (c) 2002 Free Software Foundation, Inc.
This Is Free Software; See the Source for Copying Conditions. There is no
NOTNESS for a particular purpose.
-------------------------------------------------- ---------------------------------
How to do? ? ?
-------------------------------------------------- -------------
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 / lib
Export 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_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 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.java
Import 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
$ Javac hellodate.java
$ Java Hellodate
Hello, IT's:
Thu Jun 10 14:21:21 CST 2004
OK, Java environment is built. Start writing your Java program.