1. Configure the JDK Environment
Download
Log on to the oracle website to download JDK7
Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Before downloading, We must select "Accept License Agreement" to allow downloading.
There are several linux JDK versions. Which one should I choose? Let's first look at their differences.
X86 corresponds to 32-bit operating system applications and x64 corresponds to 64-bit operating system applications, before downloading, make sure that my operating system is 32-bit or 64-bit.
Ctrl + alt + t call out the ubuntu terminal. 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
Different operating systems have two types of installation packages.
Rmp was originally a RedHat Linux release dedicated to managing Linux suites. It is popular because it complies with GPL rules and is powerful and convenient. Gradually adopted by other releases. The emergence of the RPM suite management method makes Linux easy to install and upgrade, indirectly improving the applicability of Linux.
Ar.gz is the file extension after tar and gzip compression.
Use winzip or winrar to open
What I downloaded here isJdk-7u21-linux-x64.tar.gzIn this version, jdk is installed under/opt/java.
Extract
Create directory:
Root @ fnngj-H24X:/home/fnngj/download # pwd // The default path to download the file/home/fnngj/download root @ fnngj-H24X: /home/fnngj/download # ls // download the file jdk-7u21-linux-x64.tar.gz root @ fnngj-H24X:/home/fnngj/download # sudo mkdir/usr/java // create directory root @ fnngj-H24X: /home/fnngj/download # sudo tar zxvf jdk-7u21-linux-x64.tar.gz-C/opt/java // extract the downloaded file to the/usr/java directory root @ fnngj-H24X: /home/fnngj/download # cd/opt/java // switch to the Created directory root @ fnngj-H24X:/opt/java # lsjdk1.7.0 _ 21
Rename(Optional)
To facilitate writing, we need to rename the decompressed JDK directory.
root@fnngj-H24X:/opt/java# sudo mv jdk1.7.0_21 java-7-sunroot@fnngj-H24X:/opt/java# lsC:\nppdf32Log\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=/opt/java/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 the echo command on the terminal to check the environment variable settings
root@fnngj-H24X:/usr/java# echo $JAVA_HOME/opt/java/java-7-sunroot@fnngj-H24X:/usr/java# echo $CLASSPATH.:/usr/java/java-7-sun/lib:/opt/java/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:/opt/java/java-7-sun/bin
View the installed java version:
root@fnngj-H24X:/opt/java# java -versionjava version "1.7.0_21"Java(TM) SE Runtime Environment (build 1.7.0_21-b21)Java HotSpot(TM) Server VM (build 23.6-b04, mixed mode)
Make it valid for all users
Open a terminal and view the java version.
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 Package>
Why can't I find it? Because the configuration was just configured with the root user and the terminal is closed, the role of the configuration disappears. What should we do?
You need to modify the profile file
Root @ fnngj-h24x/usr/java # sudo gedit/etc/profile
Open the profile file and add the following content:
#set java environmentJAVA_HOME=/opt/java/java-7-sunexport JRE_HOME=/opt/java/java-7-sun/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Save the modification
This requires restarting the computer to take effect, so that java jdk has been configured.
Ii. 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/opt/java/directory fnngj @ fnngj-H24X :~ /Download $ sudo tar xvfz eclipse-jee-juno-SR1-linux-gtk.tar.gz-C/opt/java // to perform this action may require entering the user password to enter the unzip directory root @ fnngj-H24X: /opt/java # cd eclipse/root @ fnngj-H24X:/opt/java/eclipse # lsabout_files configuration eclipse. ini icon. xpm p2about.html dropins epl-v10.html libcairo-swt.so 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.
1. Create a document on the desktop. Open the document and enter the content
[Desktop Entry]Categories=Development;Comment[zh_CN]=Comment=Exec= /opt/java//eclipse/eclipseGenericName[zh_CN]=IDEGenericName=IDEIcon= /opt/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
(The red path must be changed to your software installation path)
Save modified closed files
2, Rename the file to: eclipse. desktop
3. Right-click the file to add permissions
(The red path must be changed to your software installation path)
Save modified closed files
2, Rename the file to: eclipse. desktop
3. Right-click the file to add permissions
4. Then, you can click the icon to open it. (what is the size of the icon !!!!)
5. Add the shortcut to the application file.
Root @ fnngj-H24X:/desktop cp eclipse. desktop/usr/share/applications/eclipse. desktop
Remove the desktop shortcut and lock it to the starter when eclipse is started.
Add hello world