Java environment configuration in linux and linuxjava Environment
I plan to learn the Java language recently.
For beginners like me, I first wanted to experience the Java language and how to implement it...
However, o_O indicates that it is very confusing. It is also the most important thing in practice. After you configure the environment, you can start to learn more.
1. First, go to the official website:
Bytes
I downloaded a 64-bit jdk-6u13-linux-i586.bin.
2. Install jdk and open the terminal:
(1) Use root permissions, first is to change the executable permissions of the jdk-6u13-linux-i586
Using the ll command, you can see:
The executable permission of the jdk-6u13-linux-i586 is changed to: (about the user permission, I am Baidu directly, a lot of information)
(2) Next, execute jdk-6u13-linux-i586
Will generate: jdk1.6.0 _ 45
(3) then, move the generated jdk1.6.0 _ 45 to the/opt directory.
3. Configure Environment Variables
Use vi/vim to open/etc/profile to add Environment Variables
Add: (JAVA_HOME is the installation directory of JDK 1.6.0 _ 45)
P.S ).
Problem: My JAVA_HOME path has been successfully added and cannot be found when some class files are used. That is to say, the file I added cannot be found on CLASSPATH.
So I used echo $ CLASSPATH to view the class file I added to CLASSPATH. No, I thought it was an error. I have carefully modified/etc/profile several times, still does not work.
Solution: Later I changed the CLASSPATH method. I directly entered export CLASSPATH = $ CLASSPATH: $/opt/jdk1.6.0 _ 45/lib/dt. jar on the terminal.
4. test installation
Enter the version number on the terminal, indicating that the installation is successful.
Next, write a short piece of code to test it. In your own directory, enter vim Hello. java in the terminal and edit it.
Input command:
// Compile Hello. java. javac is the jdk compiler that compiles Hello. java into bytecode, that is, the generated Hello. class file.
Javac Hello. java
// Put the compiled bytecode In the interpreter for execution
Java Hello
The result is the most common Hello World! Output ~
Environment configuration complete ~