Under UbuntuApt-Get installIt's really easy to use,
If you are not sure about the package name to be installed,
You can also enter two letters startingTab keyTo give a prompt.
The following is how to install JavaJDKExample:
I want to compile and execute Java programs in Linux,
Java program needsJDKAndJVM,
The JDK package name is unknown,
Enter:
Sudo apt-Get install sun-
Then pressTab keyUbuntu will provide a list of names of all software packages starting with Java Characters Based on the software installation source,
As a result, we can see:Sun-java6-jdk,
Then complete the input: sudo apt-Get install sun-java6-jdk, (and for success, but sudo apt-Get install openjdk-6-jdk), or when you are running a Java program, you will be prompted to install something...
Complete software installation as prompted.
Write a simple programTestNext let's take a look:
Enter a directory,
Then create. JavaFile: VI test. Java
Enter the following code:
Public class test {
Public static void main (string [] ARGs ){
System. Out. println ("Hello World ");
}
}
Save and exit VI: , Press Enter.
Compile test. Java:JavacTest. Java
Run test:JavaTest
The output string is Hello world.
Indicates that JDK and JVM have been installed in the Java development environment.
You may also need to setClasspath environment variable,
Available in Ubuntu/Etc/environmentFile,
Add code:Export classpath= "Path" (note that multiple paths are usedColon: Not separated by semicolons (; different from Windows)
By the wayJava_homeAlso set: Export java_home = "/usr/lib/JVM/Java-6-sun-1.6.0.15"
Then modify the default usageOpenjdkIsSun-JDK:
Sudo Update-Alternatives-- Config Java
Select sun-JDK as prompted;
Restart your computer.