Ubuntu under the JDK environment variable configuration (to solve the problem of restarting the computer after the failure!) )

Source: Internet
Author: User

There are a number of ways to configure JDK environment variables on the web, but almost always fail the next time you restart your computer, or sometimes. Let me show you a trick.


First extract your JDK under Oracle, I take jdk1.7.0_25 as an example

Create the JVM folder with the following command.

sudo MKDIR/USR/LIB/JVM

and copy your extracted JDK to this folder.

sudo cp-rf./jdk1.7.0_25/usr/lib/jvm/


JDK environment variables are configured as follows:

Execute command sudo gedit/etc/environment, fill in an open editor as follows


Java_home= "/usr/lib/jvm/jdk1.7.0_25"
Classpath= ".: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar:/usr/lib/jvm/jdk1.7.0_25/jre/lib"
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: $JAVA _home/bin:/home/eastlhu/ Android/ndk/android-ndk-r8e:/home/eastlhu/android/sdk/android-sdk-linux/platform-tools:/home/eastlhu/android/ Sdk/android-sdk-linux/tools "



Then:

Execute command sudo gedit/etc/profile

Java_home=/usr/lib/jvm/jdk1.7.0_25
Export JRE_HOME=/USR/LIB/JVM/JDK1.7.0_25/JRE
Export classpath=.: $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH: $HOMR/bin





There are three ways to set up environment variables in Ubuntu, one for the current terminal, one for the current user, and one for all users :



one: For the current terminal:

In the current terminal enter:export path= $PATH:< your path to join >

However, the above method applies only to the current terminal, which is not valid once the current terminal is closed or in another terminal.



two: For the current User:

There is a. bashrc hidden file in the user's home directory where you can add the PATH to the following settings:

VI ~/.BASHRC

Join:

export path=< your path to join: $PATH

If you want to add multiple paths, as long as:

Export path=< The path you want to add 1>:< the path you want to add 2>: $PATH

each of these paths should be separated by a colon.

This will take effect every time you log on



Three: For all users:

sudo vi/etc/profile

Join:
Export path=< The path you want to add: $PATH

It's OK.


Terminal input:echo $PATH can view environment variables



Note that after modifying the environment variables, the second method takes effect immediately, except that the first method takes effect immediately, and you can either source ~/.BASHRC or log off again.




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.