- (offline installation) First, upload locally downloaded jdk-8u102-linux-x64.gz via WINSCP
- (offline installation) extract the jdk-8u102-linux-x64.gz to/USR/LIB/JVM and rename the folder name to Java-8-oracle:
[Email protected]:/usr/lib$ mkdir JVM
[Email protected]:/usr/lib$ ls
。。。 Jvm...
[Email protected]:/usr/lib$ Cd/home/hadoop
[Email protected]:~$ sudo cp-r jdk-8u102-linux-x64.gz/usr/lib
[Email protected]:~$ cd/usr/lib
[Email protected]:/usr/lib$ ls
..... jdk-8u102-linux-x64.gz ...
[Email protected]:/usr/lib$ sudo tar-zxvf jdk-8u102-linux-x64.gz-c jvm/
[Email protected]:/usr/lib$ CD JVM
[Email protected]:/usr/lib/jvm$ ls
jdk1.8.0_102
[Email protected]:/usr/lib$ CD .
[Email protected]:/usr/lib$ sudo rm jdk-8u102-linux-x64.gz
[Email protected]:/usr/lib$ CD JVM
[Email protected]:/usr/lib/jvm$ MV Jdk1.8.0_102/java-8-oracle
Mv:cannot move ' jdk1.8.0_102/' to ' java-8-oracle ': Permission denied
[Email protected]:/usr/lib/jvm$ sudo mv jdk1.8.0_102/java-8-oracle/
[Email protected]:/usr/lib/jvm$ ls
Java-8-oracle
[Email protected]:/usr/lib/jvm$
- Setting environment variables (offline installation)
[Email protected]:~$sudo vim/etc/ profile
Append the line to the end of the profile file:
Export Java_home=/usr/lib/jvm/java-8-oracle
Export Jre_home_/usr/lib/jvm/java-8-oracle
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Export classpath= $CLASS _path:: $JAVA _home/lib: $JAVA _home/jre/lib
(esc,:wq! Save)Hadoop@master: ~$sudo update-alternatives--install/usr/bin/java java/usr/lib/jvm/java-8-oracle/bin/javaUpdate-alternatives:using/usr/lib/jvm/java-8-oracle/bin/java to Provide/usr/bin/java (Java) in Auto modeHadoop@master: ~$sudo update-alternatives--install/usr/bin/javac javac/usr/lib/jvm/java-8-oracle/bin/javacUpdate-alternatives:using/usr/lib/jvm/java-8-oracle/bin/javac to Provide/usr/bin/javac (Javac) in Auto modeHadoop@master: ~$sudo update-alternatives-- config javathere is only one alternativeIn Link Group Java (providing/usr/bin/java):/usr/lib/jvm/java-8-oracle/bin/ javanothing to configure. Hadoop@master: ~$ sudo update-alternatives-- config javacthere is only one alternativeIn Link Group Javac (PROVIDING/USR/BIN/JAVAC):/usr/lib/jvm/java-8-oracle/bin/javacnothing to configure.
- (Off-line installation) test is installed.
Java-version I test not, so restarted the server, found can.
Java- version "1.8.0_102" Java (tm) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot (tm) 64-bit Server VM (build 25.102-b14, M ixed mode)
- Installation Java8 (online installation)
sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get Install Oracle-java8-installer
If you are prompted with "Cannot add Ppa:xxx" when you execute the sudo add-apt-repository ppa:webupd8team/java command, it is generally because the CA certificate is corrupted. Perform the following command repair:
sudo apt-get install--reinstall ca-certificates
Set the JAVA_HOME environment variable:
$ vim/etc/profile
Add a separate line to the front of the file (note that there can be no spaces before and after the = number) and save the following:
Export Java_home=/usr/lib/jvm/java-8-oracle
/* Press ESC to enter: Wq Save and Exit */
Reference: http://blog.csdn.net/sddi1989/article/details/7995042
Linux:ubuntu 14.04 Server Offline installation Jjava8 (and online installation)