Configure the Java environment in Ubuntu

Source: Internet
Author: User

 

Configure the JDK Environment

 

Download

LoginOracleTo downloadJdk7

Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Okay! Before downloading, select"Accept license agreement"Then, we can download it.

There are severalLinuxVersionJDKWhich one should be selected? Let's first look at their differences.

X86Corresponding32Applications in a bit Operating SystemProgram,X64Corresponding64Before downloading an application in the operating system, make sure that your operating system is32Bit or64Bit.

CTRL + ALT + TCall upUbuntu. Run the following command:

 
Fnngj @ fnngj-H24X :~ $ Getconf long_bit // view the number of bits in the operating system 32fnngj @ fnngj-H24X :~ $ Lsb_release-A // By The Way, check the operating system information no LSB modules are available. Distributor ID: ubuntudescription: Ubuntu 12.10 release: 12.10 codename: quantal

 

The operating system of each digit is divided into two types of installation packages..

RMP was originally RedHat Linux is released to manage Linux suite programs, because it follows GPL is widely used because of its powerful and convenient functions. Gradually adopted by other releases. RPM suite management, let Linux easy to install, upgrade indirectly improves Linux applicability.

Ar.gzIs usedTarAndGzipThe file extension after compression. UseWinZipOrWinRARYou can open

What I downloaded here isJdk-7u11-linux-i586.tar.gzThis version

On/Usr/JavaInstallJDK

Extract

Create directory:

Root @ fnngj-H24X:/home/fnngj/download # PWD // download the default path of the file/home/fnngj/download
Root @ fnngj-H24X:/home/fnngj/download # ls // download the file jdk-7u11-linux-i586.tar.gz
Root @ fnngj-H24X:/home/fnngj/download # sudo mkdir/usr/Java // create a directory
Root @ fnngj-H24X:/home/fnngj/download # sudo tar zxvf jdk-7u11-linux-i586.tar.gz-C/usr/Java // unzip the downloaded file to the/usr/Java directory
Root @ fnngj-H24X:/home/fnngj/download # cd/usr/Java // switch to the Created directory
Root @ fnngj-H24X:/usr/Java # lsjdk1.7.0 _ 11

 

Rename(Optional)

To facilitate writing, we needJDK.

Root @ fnngj-H24X:/usr/Java # sudo MV jdk1.7.0 _ 11 java-7-sunroot @ fnngj-H24X:/usr/Java # LSC: \ np1_32log \ debuglog.txt Java-7-sun

 

Modify configuration file

Open the configuration file command

Root @ fnngj-H24X: Sudo
Gedit/etc/environment

The configuration is as follows:

Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/local/games:$ Java_home/bin "Export classpath =.: $ java_home/lib: $ java_home/JRE/libexport java_home =/usr/Java-7-sun

 

(The red part shows the content we want to add. Note the path. Do not write an error in the installation version name)

Close the configuration file after saving

To make the configuration file take effect, enter the following:

Root @ fnngj-H24X:/usr/Java #Source/etc/environment

 

Verify

Use on a terminalEchoCommand to check the environment variable settings

 
Root @ fnngj-H24X:/usr/Java # echo $ java_home/usr/Java/java-7-sunroot @ fnngj-H24X:/usr/Java # echo $ classpath. /usr/Java-7-sun/lib:/usr/Java-7-sun/JRE/libroot @ fnngj-H24X: /usr/Java # echo $ path/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games:/usr/local/games:/usr/Java-7-sun/bin

 

View installedJavaVersion:

Root @ fnngj-H24X:/usr/Java # Java-versionjava version "1.7.0 _ 11" Java (TM) se Runtime Environment (build 1.7.0 _ 11-b21) Java hotspot (TM) server VM (build 23.6-b04, mixed mode)

 

 

Make it valid for all users

Open a terminal and viewJavaVersion

Fnngj @ fnngj-H24X :~ $ Java-version programs 'java' are included in the following package: * default-JRE * gcj-4.6-jre-headless * gcj-4.7-jre-headless * openjdk-7-jre-headless * openjdk-6-jre-headless try: sudo apt-Get install<Selected Software Package> 

Ah! Why can't I find it? Because we usedRootIf the terminal is closed and configured by the user, the role of the configuration disappears. What should we do?

 

Need to modifyProfileFile

Root @ fnngj-h24x/usr/Java # sudo gedit/etc/profile

Open the profile file and add the following content:

 
# Set Java environmentjava_home =/Usr/Java-7-sunExport jre_home =/Usr/Java-7-sun/Jreexport classpath =.: $ java_home/lib: $ jre_home/lib: $ classpathexport Path = $ java_home/bin: $ jre_home/bin: $ path

Save the modification

This takes effect only after you restart your computer.

 

 

 

Install eclipse

 

To use Java, eclipse is indispensable. The following is a simple task to download and install the editor.

Http://www.eclipse.org/downloads/

Select the desired version to download. The downloaded version is:

Eclipse-jee-juno-SR1-linux-gtk.tar.gz

 

Extract:

 
Switch to your system on the terminal in the directory: fnngj @ fnngj-H24X :~ $ CD download fnngj @ fnngj-H24X :~ /Download and decompress the downloaded ide To the/usr/Java/directory fnngj @ fnngj-H24X :~ /Download $Sudo tar xvfz eclipse-jee-juno-SR1-linux-gtk.tar.gz-C/usr/Java/
// To execute this action, you may need to enter the user password to enter the unzip directory root @ fnngj-H24X:/usr/Java # cd Eclipse/
Root @ fnngj-H24X:/usr/Java/eclipse # lsabout_files configuration eclipse. ini icon. XPM p2about.html dropins epl-v10.html pluginsartifacts. xml eclipse features notice.html readme

We can find the decompressed directory to run the program, but it is too inconvenient to start the program every time we go to the directory.

 

 

Generate desktop icons

Here is a simple method.

1Create a document on the desktop. Open the document and enter the content

 
[Desktop entry] categories = development; Comment [zh_cn] = comment = exec =/Usr/Java // Eclipse/eclipseGenericname [zh_cn] = idegenericname = ideicon =/Usr/Java/Eclipse/icon. XPMMimetype = Name [zh_cn] = effecsename = eclipsepath = startup1_y = trueterminal = falsetype = applicationx-region-servicename = x-region-startuptype = x-KDE-substituteuid = falsex-KDE = Owen

(The red path must be changed to your software installation path)

Save modified closed files

 

2, Rename the file:Eclipse. Desktop

 

3, Right-click the file to add permissions

 

4Then, you can click the icon to open it. (what is the size of the icon !!!!)

 

Add Hello World

 

 

------------------------------------------------

Note: This is the first time you have completed this article in Ubuntu.ArticleA year ago, I tried to switch the environment to Linux. After all, I had many years of experience using Windows, but I was not able to adapt to it, so I went back to Windows. In the past few days, I have been enthusiastic about trying to use Linux.

 

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.