Ubuntu environment configuration records: (3) Configure jdk and jdk Environment Variables

Source: Internet
Author: User

Ubuntu environment configuration records: (3) Configure jdk and jdk Environment Variables
1. Download the jdk Installation File
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
File name as jdk-6u30-linux-i586.bin


2. Copy and install to a specified directory
The specified installation directory is/usr/developer/java (Note: folders can be specified as needed)


3. Switch to the root user and execute the jdk-6u30-linux-i586.bin

1) sudo-s, switch user,./jdk-6u30-linux-i586.bin, open file.

(Note: You may still not have the execution permission at this time, because in linux, the default file permission is 644, and even the owner does not have the execution permission. In this case, you need to change the permission, if you want to know the permissions of a file, you can go to the folder where the file is located and execute the command ls-la to view it. Here, we change the permissions of the jdk-6u30-linux-i586.bin file to 777, that is, the owner user of the file, the group user and other users have all permissions on the file, of course, it is not recommended to set permissions on the files in the system, this damages the security of linux .)
Chmod 777 jdk-6u30-linux-i586.bin, change permissions.


2) execute again./jdk-6u30-linux-i586.bin
If the installation is successful, a jdk1.6.0 _ 30 folder is added to the/usr/developer/java directory.


4. Configure Environment Variables
1) Open the/etc/profile file
Sudo gedit/etc/profile


2) Add a variable
# Set java environment
Export JAVA_HOME =/usr/developer/java/jdk1.6.0 _ 30
Export JRE_HOME =/usr/developer/java/jdk1.6.0 _ 30/jre
Export CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
Export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ JAVA_HOME: $ PATH


3) after changing the/etc/profile file, you must restart the machine to make it take effect.
Here we will introduce a method to make it take effect without restarting.
Source/etc/profile


4) check whether the java environment variable is configured successfully.
Java-version
Jdk configuration in ubuntu

Use the official jdk to download it from sun! And the version is not the latest.
Download and decompress the package to a directory.
Add the PATH in. bashrc and. profile to this directory.
In addition, set the CLASSPATH variable to this directory,
(PATH should be "directory \ bin ")
If it is openjdk, you don't have to worry about it. Just install it directly.
I personally think there is no difference between openjdk and sun's jdk .......

JDK environment variable configuration in ubuntu

Sudo gedit/etc/environment

Add the following content and save and exit

Export JAVA_HOME =/home/gong/jdk1.6.0 _ 25
Export CLASSPATH = ..: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib
PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: $ JAVA_HOME/bin"

Note:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games must be retained; otherwise, the system cannot be logged on.
<P> # echo $ JAVA_HOME </p>

<P> # echo $ CLASSPATH </p>

<P> # echo $ PATH </p>

<P> 5. Check whether jdk is successfully installed </p>

<P> java-version </p>

Related Article

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.