Transferred from: http://www.cnblogs.com/fnng/archive/2013/01/30/2883815.html
Configuring the JDK Environment
Download
Login to Oracle's website to download JDK7
Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
All right! Before downloading, we must select "Accept License Agreement" before allowing us to download.
There are several Linux versions of the JDK, so you should choose that? Let's see what's different about them first.
x86 corresponds to the application under the 32-bit operating system,x64 the application under the 64-bit operating system, then we must first determine whether my operating system is 32-bit or 64-bit before downloading.
Ctrl+alt+t bring up Ubuntu's terminal. Enter the command:
[Email protected]:~$ getconf long_bit//View operating system bits 32[email protected]:~$ lsb_release-a//By the way look at operating system Information no LSB modules is avail Able. Distributor ID:UbuntuDescription:Ubuntu 12.10release:12.10codename:quantal
There are two different types of installation packages for each of the human-digit operating systems .
RMP was originally a RedHat Linux distribution program designed to manage Linux packages and is popular because it follows GPL rules and is powerful and convenient. is gradually being adopted by other distributions. the advent of RPM suite management means that Linux is easy to install and upgrade, which indirectly increases the applicability of Linux.
Ar.gz is the file extension that was compressed with tar and gzip. You can open it with WinZip or winrar .
I'm downloading this version of jdk-7u11-linux-i586.tar.gz here.
I installed the jdk under/usr/java .
Extract
To create a directory:
[Email protected]:/home/fnngj/Download # pwd //download file default path/home/fnngj/download
[Email protected]:/home/fnngj/download # ls //view the downloaded file jdk-7u11-linux-i586.tar.gz
[Email protected]:/home/fnngj/download # sudo mkdir/usr/java //Create Directory
[Email protected]:/home/fnngj/download # sudo tar zxvf jdk-7u11-linux-i586.tar.gz-c/usr/java//Unzip the downloaded file into the/usr/java directory
[Email protected]:/home/fnngj/Download # cd/usr/java/ //switch to the created directory
[Email protected]:/usr/java# lsjdk1.7.0_11
renaming (non-mandatory steps)
For the sake of writing, we need to rename the directory of the JDK to be unpacked.
[Email protected]:/usr/java# sudo mv jdk1.7.0_11 java-7-sun[email protected]:/usr/java# lsc:\nppdf32log\debuglog.txt< C7/>java-7-sun
Modifying a configuration file
Open configuration File command
[Email protected]: sudo gedit/etc/environment
The configuration content 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/java-7-sun
(The red part is the content we want to add, note the path, install the version name do not write wrong)
Close profile after saving
For the configuration file to take effect, you need to enter:
[Email protected]:/usr/java# source/etc/environment
Verify
Use the echo command at the terminal to check the settings of environment variables
[Email protected]:/usr/java# echo $JAVA _home/usr/java/java-7-sun[email protected]:/usr/java# echo $CLASSPATH.:/ Usr/java/java-7-sun/lib:/usr/java/java-7-sun/jre/lib[email protected]:/usr/java# Echo $PATH/usr/local/sbin:/usr/ Local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/java/java-7-sun/bin
To view the installed Java version:
[Email protected]:/usr/java# java-versionjava Version "1.7.0_11" Java (TM) SE Runtime Environment (build 1.7.0_11-b21) Jav A HotSpot (TM) Server VM (build 23.6-b04, Mixed mode)
Make it valid for all users
Reopen a terminal to view the Java version
Ah! Why can't I find it? Because it was configured with the root user, and the terminal is closed, the function of the configuration disappears. So what?
The profile file needs to be modified
[Email protected]/usr/java# sudo gedit/etc/profile
Open the profile file and add the following:
#set java environmentjava_home=/usr/java/java-7-sunexport jre_home=/usr/java/java-7-sun/jreexport CLASSPATH=.:$ Java_home/lib: $JRE _home/lib: $CLASSPATHexport path= $JAVA _home/bin: $JRE _home/bin: $PATH
Save after modification is complete
This requires restarting the computer to take effect.
Install Eclipse
To play Java, the Eclipse is the tool. The following work is simple. Download the installation editor.
http://www.eclipse.org/downloads/
Select the version you want to download, I download the version is:
Eclipse-jee-juno-sr1-linux-gtk.tar.gz
Unzip :
Switch to your system in the terminal directory: [email protected]:~$ cd Download [email protected]:~/download Unzip the downloaded IDE to/usr/java/directory [email protected]:~/download sudo tar XVFZ eclipse-jee-juno-sr1-linux-gtk.tar.gz-c/usr/java/
Performing this action may require entering the user's password into the extract directory [email protected]:/usr/java# cd eclipse/
[Email protected]:/usr/java/eclipse#
We can find the unpacked directory to run the program, but it is inconvenient to start the program every time we go to the directory.
Generate desktop icons
Here's a simple way to teach you.
1. Create a document on the desktop. Open the document and enter the contents
[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]=eclipsename=eclipsepath=startupnotify=trueterminal=falsetype= Applicationx-dbus-servicename=x-dbus-startuptype=x-kde-substituteuid=falsex-kde-username=owen
(Red two paths need to be modified to the installation path of your software)
Modify finish Save close file
2. Rename the file to:eclipse.desktop
3, right-click File to increase permissions
4, then, you can click on the icon to open, (what the situation icon so BIG!!!!) )
Finally attached Hello World
------------------------------------------------
Note, the first time to complete this article under Ubuntu, a year ago to try to use the environment to switch to Linux, after all, many years of Windows use habits, a variety of not adapt, and then honestly back to Windows. These days have a passion to try various uses under Linux.
Configure Java environment "Go" under Ubuntu