Establishment of Java Development Environment in Linux

Source: Internet
Author: User
The establishment of the Java Development Environment in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. Get JDK, http://java.sun.com download the latest JDK jdk-6-linux-i586.bin
2. Install JDK (as root)
Decompress the bin package
[Root @ localhost root] # mkdir/usr/java/
[Root @ localhost root] # cp jdk-6-linux-i586.bin/usr/java/
[Root @ localhost root] # cd/usr/java/
[Root @ localhost java] #./jdk-6-linux-i586.bin
[Root @ localhost java] # rm-f jdk-6-linux-i586.bin
[Root @ localhost java] # gedit/root/. bash_profile &


#. Bash_profile

# Get the aliases and functions
If [-f ~ /. Bashrc]; then
.~ /. Bashrc
Fi

# User specific environment and startup programs

PATH = $ PATH: $ HOME/bin
BASH_ENV = $ HOME/. bashrc
USERNAME = "root"

JAVA_HOME =/usr/java/jdk1.6.0
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.:/usr/java/jdk1.6.0/lib: $ CLASSPATH


Export USERNAME BASH_ENV path classpath JAVA_HOME


Make the configuration take effect
[Root @ localhost java] # source/root/. bash_profile
Check whether some environment variables have been successfully configured.
[Root @ localhost java] # env
If the following information is similar, the setting is successful:

PATH =/usr/java/jdk1.6.0/bin:/usr/java/j2sdk1.4.2 _ 01/bin:/usr/local/sbin:/usr/local/bin:/sbin: /bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

CLASSPATH =.:/usr/java/jdk1.6.0/lib:

[Root @ localhost java] # mkdir/home/workspace/helloworld
[Root @ localhost java] # cd/home/workspace/helloworld
Write the simplest Java program
[Root @ localhost helloworld] # vi hello. java
Enter the following content:
Class hello
{
Public static void main (String [] args)
{
System. out. println ("Hello world! My Java! ");
}
}

Compile
[Root @ localhost helloworld] # javac hello. java
Run
[Root @ localhost helloworld] # java hello
Hello world! My Java!


3. Install Eclipse
First download Eclipse, web site for the current http://www.eclipse.org, Eclipse version 3.2.1,
Download its gtk version to the/opt Directory: eclipse-SDK-3.2.1-linux-gtk.tar.gz
[Root @ localhost root] # cd/opt
[Root @ localhost opt] #
[Root @ localhost opt] # tar zxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz
[Root @ localhost opt] # cd eclipse
[Root @ localhost eclipse] # ls
About_files configuration eclipse. ini features libcairo-swt.so plugins startup. jar
About.html eclipse epl-v10.html icon. xpm notice.html readme
[Root @ localhost eclipse] #./eclipse &
[1] 16161
[Root @ localhost eclipse] #

Compile the first Eclipse Java program.
File-> New-> Project...
Select a Java Project, click Next, enter the Project name: hello, and click Finish to create a Project.
Can I see the hello string in the Workspace on the left?
Right-click it, select New-> Class, enter the Class Name: hello, and click Finish.
At this time, the editing page appears in the middle of Eclipse. Enter the following content:

Public class hello {

/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
System. out. println ("Hello world! My Java! ");
}

}

Save and compile now.
Can I see the hello. java string in the Workspace on the left?
Right-click it and choose Run as-> 1 Java Application to compile and pull
In the lower Console dialog box of Eclipse, output:
Hello world! My Java!
Yes?

It's that simple.

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.