To configure the JDK environment variable:
When you start the terminal and enter
- Gedit/etc/profile
Add the configuration at the end, save and exit
- #set JDK Environment
- Export java_home=/usr/lib/jvm/jdk1.7.0_21
- Export classpath=.:$JAVA _home/lib:$JAVA _home/jre/lib:$CLASSPATH
- Export path=$JAVA _home/bin:$JAVA _home/jre/bin:$PATH
Terminal input command to make configuration effective
- Source/etc/profile
4. See if the configuration is successful. In the terminal input
- Java-version
If the display version is 1.7.0.21, the configuration succeeds, as shown below:
- Java version "1.7.0_21"
- Java (TM) SE Runtime Environment (build 1.7.0_21-B11)
- Java HotSpot (TM) Server VM (build 23.21-b01, Mixed mode)
If the display is still OPENJDK, perform step 5, test again
5, configure default Jdk,ubuntu under Default JDK is OPENJDK. Terminal input
- sudo update-alternatives--install/usr/lib/java Java/usr/lib/jvm/jdk1.7.0_17/bin/java 300
- sudo update-alternatives--install/usr/lib/javac Javac/usr/lib/jvm/jdk1.7.0_17/bin/javac 300
Execute the following command to configure the default JDK
- sudo update-alternatives--config java
The JDK version is listed, which is labeled "*" as the default JDK. If you want to maintain the current default JDK, press ENTER directly, otherwise enter the number of the corresponding JDK to set it as the default version.
Configuring JDK environment variables under Ubuntu