No Java program, as a novice Java, before writing the first Hello,world program, first in Ubuntu to build a Java development environment.
First, JDK installation
OK, I choose JDK1.6, is it a bit out?
1, download JDK1.6, you can go to the official website to download, download please see your system version, remember to download the corresponding version.
Http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
2. Place the downloaded file in the/usr/lib/java directory (you need to create the Java directory manually) and modify the executable permissions for the file, such as chmod 777 Jdk-6u41-linux-x64.bin
PS: If you are prompted to have file Java, you cannot create Java, you can name the directory java1.6 (this is JDK version 1.6) "
3, installation files, sudo./jdk-6u41-linux-x64.bin
4, after installation, you need to configure the system environment sudo vi/etc/environment, or configure the user environment variable VI/HOME/USERNAME/.BASHRC, establish Javahome, CLASSPATH, modify the PATH variable
As my setting is:
Copy Code code as follows:
Java_home= "/usr/lib/java1.6/jdk1.6.0_41″
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/java1.6/jdk1.6.0_41/bin :/usr/lib/java1.6/jdk1.6.0_41/jre/bin "
Classpath= "/usr/lib/java1.6/jdk1.6.0_41/lib:/usr/lib/java1.6/jdk1.6.0_41/jre/lib"
5, execute the command, make the configuration effective. Source/etc/environment (SOURCE/HOME/USERNAME/.BASHRC)
6, verify the installation is completed, use java-version or direct use of javac, to see whether it is effective or not.
7, if it has not yet entered into force, it is likely that Ubuntu already has a default JDK, such as OPENJDK, so, in order to make the default use of our installed JDK, we have to do the following work.
Copy Code code as follows:
sudo update-alternatives–install/usr/bin/java Java/usr/lib/java/jdk1.6.0_41/bin/java 300
sudo update-alternatives–install/usr/bin/javac Javac/usr/lib/java/jdk1.6.0_41/bin/javac 300
This step adds the JDK we have installed to the Java menu.
Then execute:
Copy Code code as follows:
Update-alternatives–config Java
Second, MyEclipse installation
installation package Download Address: http://www.my-eclipse.cn/history.html
After the download is complete, the Modify permissions are executed directly to install.
Third, the first Hello World program
1 Create a new Java project, named HelloWorld
2 in a new package, the package name is Com.cricode
3 Create a new class SayHello in the package Com.cricode, which reads as follows:
Copy Code code as follows:
Package Com.cricode;
public class SayHello {
public static void Main (string[] args) {
System.out.println ("Hello,world");
}
}
Run Result: Hello,world
At this point, the Java development environment on Linux is installed.