Ubuntu builds Java development environment notes _java

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.