Several ways to install the configuration Java environment jdk1.6

Source: Internet
Author: User


Method One

I. Decompression installation JDK

Enter the directory where the Jdk-6u14-linux-i586.bin file is located under the shell terminal,
Execute the command./jdk-6u14-linux-i586.bin at this time will appear a protocol, even after knocking enter, when asked whether the consent, enter Yes, carriage return. A jdk1.6.0_14 directory will then be generated in the current directory, and you can copy it to any directory.

Two. Environment variables that need to be configured

1. Path environment variable. The function is to specify the command search path, and when executing a command under the shell, it will look in the path specified by the path variable to see if the appropriate command program can be found. We need to add the bin directory in the JDK installation directory to the existing path variable, the bin directory contains the frequently used executable files such as Javac/java/javadoc wait, after setting the path variable, you can execute Javac/java tools in any directory.
2. CLASSPATH environment variables. The role is to specify the class search path, to use the classes that have been written, and, of course, to find them, and the JVM is to look for the class through classpth. We need to set the Dt.jar and Tools.jar in the Lib subdirectory under the JDK installation directory to classpath, of course, the current directory "." must also be added to the variable.
3. Java_home environment variables. It points to the installation directory of the JDK, and software such as Eclipse/netbeans/tomcat searches Java_home variables to find and use the installed JDK.

Three. Three ways to configure environment variables 1. modifying/etc/profile files

If your computer is only recommended for development use, because all users ' shells have the right to use these environment variables, it may pose a security problem for the system.

• Open/etc/profile with a text editor
• At the end of the profile file, add:

Export java_home=/usr/share/jdk1.6.0_14
export path= $JAVA _home/bin: $PATH
export classpath=.: $JAVA _home/ Lib/dt.jar: $JAVA _home/lib/tools.jar

• Re-logon
• annotations

A. You want to change the/usr/share/jdk1.6.0_14 to your JDK installation directory
B. Linux with colon ":" to separate the path
C. $PATH/$CLASSPATH/$JAVA _home is used to refer to the value of the original environment variable
When setting an environment variable, be especially careful not to overwrite the original value, which is a

Common mistakes.

D. Classpath current directory "." Can not be lost, the current directory to throw away is also a common mistake.
E. Export is the exporting of these three variables to global variables.
F. Capitalization must be strictly differentiated.

2. Modify the. bash_profile file
This method is more secure, it can control the use of these environment variables to the user level, if you need to give a user permission to use these environment variables, you only need to modify their own user's home directory of the. bash_profile file.
• Open the. bash_profile file in the user directory with a text editor
• At the end of the. bash_profile file, add:

Export java_home=/usr/share/jdk1.6.0_14
export path= $JAVA _home/bin: $PATH
export classpath=.: $JAVA _home/ Lib/dt.jar: $JAVA _home/lib/tools.jar

3. Set the variables directly under the shell

Do not agree to use this method, because the shell, your settings are invalid, so this method is only temporary use, later to use the time to reset, more trouble.
Just execute the following command at the shell Terminal:

Export java_home=/usr/share/jdk1.6.0_14
export path= $JAVA _home/bin: $PATH
export classpath=.: $JAVA _home/ Lib/dt.jar: $JAVA _home/lib/tools.jar

Four. Test JDK

    1. Create a new Test.java file with a text editor, enter the following code in it, and save:

public class Test {public
static void Main (String args[]) {
System.out.println ("A new JDK test!");
} 
  
   }
  

Five. Uninstall JDK

• Locate the _uninst subdirectory of the JDK installation directory
• Execute commands at the shell terminal./uninstall.sh can uninstall the JDK.


Method Two

First, installation

Create the installation directory, set up the installation path under/usr/java, and test the file into the path:

# Mkdir/usr/java

1, Jdk-6u11-linux-i586.bin This is a self-extracting file, installed on Linux is as follows:

# chmod 755 jdk-6u11-linux-i586.bin
#/jdk-6u11-linux-i586.bin (Note that this step must be in the Jdk-6u11-linux-i586.bin directory)

The JDK is uncompressed after you press the prompt to enter Yes.

There is a line of words: Do your aggree to the above license terms? [Yes or No]

The installer is asking if you are willing to follow the license agreement you have just read. Of course you have to agree, enter "Y" or "yes" return.

2, if the use of Jdk-6u11-linux-i586-rpm.bin This is also a self-extracting file, but the extracted file is jdk-6u11-linux-i586-rpm package, the implementation of RPM commands installed on Linux on it. The installation is as follows:

#chmod 755/jdk-6u11-linux-i586-rpm.
/jdk-6u11-linux-i586-rpm. bin
# RPM-IVH jdk-6u11-linux-i586-rpm

There is a line of words: Do your aggree to the above license terms? [Yes or No]

The installer is asking if you are willing to follow the license agreement you have just read. Of course you have to agree, enter "Y" or "yes" return.

The installation software automatically installs the JDK into the/usr/java/directory.

Second, the configuration
#vi/etc/profile

Add the following inside

Export java_home=/usr/java/jdk1.6.0_27 export
java_bin=/usr/java/jdk1.6.0_27/bin
export path= $PATH: $JAVA _ Home/bin
export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
export java_home java_bin PATH CLASSPATH

Let the/etc/profile file become effective immediately after modification, you can use the following command:

# . /etc/profile

Attention:. and/etc/profile have spaces.


Restart Test

Java-version
Screen Output:
java Version "jdk1.6.0_02"
Java (TM) 2 Runtime environment, Standard Edition (Build J dk1.6.0_02)
Java HotSpot (TM) Client VM (build jdk1.6.0_02, Mixed mode)

Method Three


First, download Java
URL: http://www.oracle.com/technetwork/java/javase/downloads/index.html
I'm under Jdk-6u43-linux-i586.bin.

Second, the installation
1, I was under the opt to create a new Java folder
#mkdir/opt/java

2, I use the winscp to put the JDK files into the/usr/java folder
When placed, execute the following command:

#cd/opt/java

#chmod a+x jdk-6u43-linux-i586.bin


Enable the current user to have the execution authority to the Jdk-6u43-linux-i586.bin;

3. Perform installation

./jdk-6u43-linux-i586.bin


Run Jdk-6u43-linux-i586.bin, this will show the JDK installation license Agreement, by the Space page, the final program will ask you to agree with the above agreement, of course, agree, enter "yes" after the JDK to the current directory. The progress of the decompression is displayed on the screen at this time.
After the decompression is complete, a new directory named "Jdk1.6.0_43" will be created under the/opt/java directory, so we have installed the JDK under CentOS.
4. Open/etc/profile with text editor
# Vi/etc/profile


Add the following lines at the end:

Export java_home=/opt/java/jdk1.6.0_43

export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar:$ Java_home/lib/tools.jar

export path= $PATH: $JAVA _home/bin

Three, delete/uninstall


Remove the JDK with the #rm-fr jdk1.6.0_43 command, and don't forget to empty the contents of the configuration file.

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.