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.