recently in research Jarsigner APK, found that Jarsigner command was not found, and later found that I was installed after the JDK environment variables are not configuredOn the Internet to find the relevant information, thank
http://my.oschina.net/boltwu/blog/403555
1. Download JDK
The Linux operating system is: centos6.5-x64
The current version of the JDK is: Java SE Development Kit 7u80
Download Address: http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
View Latest: Http://www.oracle.com/technetwork/java/javase/downloads/index.html
All versions archive Download address: http://www.oracle.com/technetwork/java/javase/archive-139210.html 2. Decompression installation
We install the JDK to this path:/usr/local/java
If this directory is not there (for the first time, of course not), we will create a new directory
cd/usr/local
sudo mkdir java
After the establishment, we came to just download the good compressed package directory, extract to our newly created folder inside, and modify the good name to facilitate our management
sudo tar zxvf./jdk-7u80-linux-x64.tar.gz -c/usr/local/java
cd/usr/local/java
sudo mv jdk1.7.0_80 jdk1.7.0
3. Configure Environment Variables
VI ~/.bash_profile
Add at the end of an open file
# Export Java env
export java_home=/usr/local/java/jdk1.7.0
export JRE_HOME=/USR/LOCAL/JAVA/JDK1.7.0/JRE
Export Classpath=.:%java_home%/lib/dt.jar:%java_home%/lib/tools.jar
export path= $JAVA _home/bin: $JRE _ Home/bin: $PATH
Save the exit and enter the following command to make it effective
SOURCE ~/.bash_profile
4. Configure the default JDK (this step can be omitted in general)
The default JDK, such as OPENJDK, is already present in some Linux distributions. So to make the JDK version that we just installed become the default JDK version, we have to do the following configuration.
Execute the following command:
sudo update-alternatives--install/usr/bin/java java/usr/local/java/jdk1.7.0/bin/java-
sudo Update-alternatives--install/usr/bin/javac Javac/usr/local/java/jdk1.7.0/bin/javac-
sudo Update-alternatives--install/usr/bin/jar Jar/usr/local/java/jdk1.7.0/bin/jar-
sudo update-alternatives- Install/usr/bin/jcontrol Jcontrol/usr/local/java/jdk1.7.0/bin/jcontrol-
sudo update-alternatives--install/ USR/BIN/JPS JPS/USR/LOCAL/JAVA/JDK1.7.0/BIN/JPS 300
Note: If the above two commands do not find the path problem, just restart the computer to repeat the above two lines of code OK.
You can also use the update-alternatives--remove command to remove the path configuration as follows:
sudo update-alternatives--remove Javac/usr/local/java/jdk1.7.0/bin/javac
Perform the following code to see the current various JDK versions and configurations:
sudo update-alternatives--config java
Open a terminal and enter the following command: 5. Test
Java-version
Show Results:
Java version "1.7.0_80"
Java (tm) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot (tm) 64-bit Server VM (bu ILD 24.80-b11, Mixed mode)
This means that the Java command is ready to run.