Home>

Directly on the implementation process:

I. Decompress and install jdkEnter the directory where the jdk-6u14-linux-i586.bin file is located in a shell terminal,

Run the command ./jdk-6u14-linux-i586.bin At this time, a protocol will appear,Successive knocks on the carriage return,When asked if I agree,Enter yes and press Enter. After that, a jdk1.6.0_14 directory will be generated in the current directory. You can copy it to any directory.

Environment variables that need to be configured1. path environment variable.The role is to specify the command search path,When executing commands under the shell,It will look in the path specified by the path variable to see if it can find the corresponding command program.We need to add the bin directory under the jdk installation directory to the existing path variable. The bin directory contains frequently used executable files such as javac/java/javadoc and wait. After setting the path variable, you can use it in any directory Now execute javac/java and other tools.

2. The classpath environment variable.The role is to specify the class search path,To use already written classes,The premise is of course that they can be found,JVM finds classes by classpth.We need to set dt.jar and tools.jar in the lib subdirectory of the jdk installation directory to the classpath. Of course, the current directory "." Must be added to this variable.

3. The java_home environment variable.It points to the jdk installation directory,Software such as eclipse/netbeans/tomcat is to search for the java_home variable to find and use the installed jdk.

Three. Three ways to configure environment variables

1. Modify the/etc/profile fileIf your computer is recommended for development use only,Because all users' shells have access to these environment variables,May cause security issues to the system.

Open/etc/profile with a text editor

Add at the end of the profile file:

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-register

·annotationa. You want to change /usr/share/jdk1.6.0_14 to your jdk installation directory

b. Use ":" to separate paths under Linux

c. $path/$classpath/$java_home is used to refer to the value of the original environment variable

When setting environment variables, pay special attention not to overwrite the original value,This is a

Common mistakes.

d. The current directory "." in the classpath cannot be lost. It is also a common mistake to lose the current directory.

e. export is to export these three variables as global variables.

f. Case must be strictly distinguished.

2. Modify the .bash_profile file

This method is more secure,It can control the permissions to use these environment variables to the user level,If you need to give a user permission to use these environment variables,You just need to modify its personal user home directory.The bash_profile file is fine.

Use a text editor to open the user directory.bash_profile file

Add at the end of the .bash_profile file:

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-register

3. Set variables directly in the shell

Deprecated.Because changing the shell, your settings are invalid.So this method is only used temporarily,Set it up again when i want to use it later,kind of hard.

Just execute the following commands in a 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 it:

public class test {
public static void main (string args []) {
system.out.println ("a new jdk test!");
}
}

2. Compile:execute the command javac test.java in the shell terminal

3. Run:execute the command java test in the shell terminal

When "a new jdk test!" Appears in the shell, jdk runs normally.

V. Uninstall jdk

Find the _uninst subdirectory of the jdk installation directory

Execute commands in a shell terminal./uninstall.sh will uninstall jdk.

  • Previous Detailed object pointers and object arrays in C ++
  • Next ASPNET MVC3 teaches you how to build the Web