OSW requires JAVA
Next JDK 7 said what GBLIC 2.4 should go to rpm sercache. COM without REDHATLINUX
When redahat websit is used, if there is no version 2.4.
Later, the next JDK6 http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html
Now more and more friends are using linux. A few days ago, two friends asked me how to configure the java environment in linux. I think many other friends want to learn about this, write a complete linux java environment configuration. I hope it will help you. I. download jdk for linux to sun home page http://java.sun.com/j2se/1.5.0/download.jsp download jdk Installation File jdk-1_5_0_05-linux-i586.bin 2. decompress and install jdk under the shell terminal to enter the directory of the jdk-1_5_0_05-linux-i586.bin file, execute the command. /jdk-1_5_0_05-linux-i586.bin at this time there will be an agreement, continue to press enter, when asked whether to agree, enter yes, press Enter. A jdk-1.5.0_05 directory will be generated under the current directory, you can copy it to any directory. 3. environment variable to be configured 1. PATH environment variable. The function is to specify the command search PATH. When you execute a command under shell, it searches for the PATH specified by the PATH variable to see if the corresponding command program can be found. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/java/javadoc waiting, after setting the PATH variable, You can execute tools such as javac and java in any directory. 2. CLASSPATH environment variable. The function is to specify the Class search path and use the classes that have already been compiled. The premise is that you can find them, and JVM searches for classes through CLASSPTH. We need to set dt. jar and tools. jar in the lib subdirectory under the jdk installation directory to 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 find and use the installed jdk by searching the JAVA_HOME variable. 4. method 1. modify the/etc/profile file. If your computer is only recommended for development and use, all users' shells have the right to use these environment variables, which may cause security issues to the system. · Open/etc/profile in a text editor. Add JAVA_HOME =/usr/share/jdk1.5.0 _ 05 PATH = $ JAVA_HOME/bin: $ path classpath = to the end of the profile file.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar export JAVA_HOME export PATH export CLASSPATH · log on again
· Annotation. change/usr/share/jdk1.5.0 _ 05jdk to your jdk installation directory B. in linux, use the colon ":" to separate the path c. $ PATH/$ CLASSPATH/$ JAVA_HOME is used to reference the original environment variable value. When setting the environment variable, pay special attention not to overwrite the original value, this is a common error. D. The current directory "." In CLASSPATH cannot be lost. It is also a common error to discard the current directory. E. export exports the three variables as global variables. F. Case sensitivity is required. 2. modify. bashrc files are more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify. you can use the bashrc file. · Open. bashrc file · in. add: set JAVA_HOME =/usr/share/jdk1.5.0 _ 05 export JAVA_HOME set PATH = $ JAVA_HOME/bin: $ PATH export PATH set CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar export CLASSPATH. log on again. setting variables directly in shell does not approve of this method. If you change the shell, your settings will be invalid. Therefore, this method is only for temporary use and will be re-set in the future, it is troublesome. Run the following command on the shell terminal: export JAVA_HOME =/usr/share/jdk1.5.0 _ 05 export PATH = $ JAVA_HOME/bin: $ PATH export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
5. test jdk 1. create a Test in the text editor. java file, enter the following code and save: public class test {public static void main (String args []) {System. out. println ("A new jdk test! ") ;}} 2. Compile: Execute the command javac Test. java on the shell Terminal 3. Run: Execute the command java Test on the shell terminal when" A new jdk test! "appears under the shell !" Jdk runs normally. 6. uninstall jdk. Find the _ uninst subdirectory In the jdk installation directory. Run the command./uninstall. sh on the shell terminal to uninstall jdk.
JAVA reports an error.
[Root @ localhost software_insetall] # java test
Exception in thread "main" java. lang. NoClassDefFoundError: test
Caused by: java. lang. ClassNotFoundException: test
At java.net. urlclassloader $ 1.run( urlclassloader. Java: 202)
At java. Security. accesscontroller. doprivileged (native method)
At java.net. urlclassloader. findclass (urlclassloader. Java: 190)
At java. Lang. classloader. loadclass (classloader. Java: 306)
At sun. Misc. launcher $ appclassloader. loadclass (launcher. Java: 301)
At java. Lang. classloader. loadclass (classloader. Java: 247)
Cocould not find the main class: Test. program will exit.
Apply the classpath in the/etc/profile file
Method 1:
To make the/etc/profile file take effect immediately after modification, run the following command:
#./Etc/profile
Note: There are spaces between. and/etc/profile.
Method 2:
To make the/etc/profile file take effect immediately after modification, run the following command:
# Source/etc/profile
Then JAVA succeeded.