Environment Variables for Java

Source: Internet
Author: User

1: To the Java official website http://www.java.com/zh_CN/download/manual.jsp Download, the corresponding Java version. Do not download the wrong, or later can not use, but also have to reinstall the installation. For 32-bit Linux, it is recommended to download the Linux RPM (self-extracting file) file size: 20.1 MB , the file name after download, similar to jdk-6u22-linux-i586.rpm.

Related installation process, can refer to:

Http://www.java.com/zh_CN/download/help/linux_x64rpm_install.xml

2: Open the terminal and go to the JDK download directory, such as Cd/home/yourname/downloads/jdk-6u22-linux-i586.bin

3: Move the file to the/usr/java directory: Mv/home/yourname/downloads/jdk-6u22-linux-i586.bin/usr/java

4: Enter into the/usr/java directory: Cd/usr/java

5: Add executable permissions to all users, adding permissions to files: chmod a+x jdk-6u22-linux-i586.bin

6: Install:./jdk-6u22-linux-i586.bin

7: A folder is automatically generated after installation: Jdk-1.6.0_22

8: Modify config Java environment variable: vi/etc/profile

    • Add a few lines of code at the end of the file:

    • #set Java Environment

Export java_home=/usr/java/jdk-1.6.0_22/
Export Jre_home=/usr/java/jdk-1.6.0_22/jre/
Export path= $JAVA _home/bin: $JRE _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/: $JRE _home/lib: $CLASSPATH


9:

Save, exit, restart Linux, and then

Or

[[email protected] etc]# source/etc/profile← can take effect without restarting the machine

Log off the user and re-enter the system to check whether the configuration was successful with the following command: Java-version,java,javac

10:

View version:
Rpm-qa|grep JDK
Unloading:
RPM-E--nodeps Jdk-1.6.0_25-fcs

11:

Note:

To make the JDK available to all users, you can:

vi/etc/profile.d/java.sh

In the new java.sh, enter the following:

#set Java Environment

Java_home=/usr/java/jdk-1_5_0_02

Classpath=.:$java_home/lib/tools.jar

Path=$java_home/bin:$path

Export Java_home CLASSPATH PATH

Save exit and assign permissions to java.sh: chmod 755/etc/profile.d/java.sh

Law II:

1. Download:Jdk-1_5_0_06-linux-i586-rpm.bin
Address:http://java.sun.com/j2se/1.5.0/download.jsp
2. Add executable permissions to the file
[Email protected] java]# chmod +xJdk-1_5_0_06-linux-i586-rpm.bin
3. Executive Jdk-1_5_0_06-linux-i586-rpm.bin
[Email protected] java]#.Jdk-1_5_0_06-linux-i586-rpm.bin
Generate jdk-1_5_0_06-linux-i586-rpm after execution
4. Installing jdk-1_5_0_06-linux-i586-rpm
[Email protected] java]# RPM-IVHjdk-1_5_0_06-linux-i586-rpm
Here I have the JDK installed in the/usr/java directory
5. Configure Environment variables
There are three ways to configure environment variables (Modify the/etc/profile file, modify the. bashrc file in the user directory, and modify it directly under the shell)
All I'm saying here is that I'm using the Modify/etc/profile file
[Email protected] java]# Vi/etc/profile
After opening the file, press the I key to add after the file:

650) this.width=650; "align=" Top "src=" Http://www.blogjava.net/Images/OutliningIndicators/None.gif "title=" under Linux <wbr>java environment Configuration "style=" Margin:0px;padding:0px;border:0px;list-style:none; "/>Java_home=/usr/Java/Jdk1.5. 0_06
650) this.width=650; "align=" Top "src=" Http://www.blogjava.net/Images/OutliningIndicators/None.gif "title=" under Linux <wbr>java environment Configuration "style=" Margin:0px;padding:0px;border:0px;list-style:none; "/> PATH=$JAVA _home/ Bin: $PATH
650) this.width=650; "align=" Top "src=" Http://www.blogjava.net/Images/OutliningIndicators/None.gif "title=" under Linux <wbr>java environment Configuration "style=" Margin:0px;padding:0px;border:0px;list-style:none; "/> CLASSPATH=.: $JAVA _home/Lib/Tools.jar: $JAVA _home/Lib/ Dt.jar
650) this.width=650; "align=" Top "src=" Http://www.blogjava.net/Images/OutliningIndicators/None.gif "title=" under Linux <wbr>java environment Configuration "style=" Margin:0px;padding:0px;border:0px;list-style:none; "/> Export JAVA_HOME PATH CLASSPATH
650) this.width=650; "align=" Top "src=" Http://www.blogjava.net/Images/OutliningIndicators/None.gif "title=" under Linux <wbr>java environment Configuration "style=" Margin:0px;padding:0px;border:0px;list-style:none; "/>

Press the ESC key
Input: Wq save exit.
Log in again


Environment Variables for Java

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.