No Java program, as a novice Java, before writing the first Hello,world program, first in Ubuntu to build a Java development environment.
This article structure:
- First, JDK installation
- Second, MyEclipse installation
- Third, Hello World test
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.
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, Create Javahome, CLASSPATH, and modify path variables
As my setting is:
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.
sudo update-alternatives–install/usr/bin/java java/usr/lib/java/jdk1.6.0_41/bin/java-
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:
update-alternatives–config Java
Second, myeclipse installation
installation package download, after the download is complete, modify permissions to execute 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:
Package Com.cricode;
public class SayHello {public
static void Main (string[] args) {
System.out.println ("Hello,world");
}
Run Result: Hello,world
At this point, Linux Java Development environment installed, I hope you like.