Download the JDK installation file from java.sun.com, which is generally in the format of jdk1.5.0 _ 10_xxxx.bin.
Unbind the JDK Directory, which is/usr/Java/jdk1.5.0 _ 10/
| Code: |
| Sudo gedit/etc/profile |
Append at the end of the file:
| Code: |
Export java_home =/usr/Java/jdk1.5.0 _ 10/
# Note: append the bin directory of the newly added JDK to the beginning of $ path. In this way, when multiple JDK versions are installed in the system, the program will first search for the JDK version at the beginning.
Export Path = $ java_home/bin: $ path
Export classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/dt. jar: $ classpath |
After saving/etc/profile, do not forget to execute the following command to make changes to environment variables take effect immediately.
If an error is reported when you run the preceding command, check whether the text you added in/etc/profile is incorrect.
Finally, check whether the environment variable changes take effect: