在 CentOS 1804 中手動安裝 JDK 1.8
阿新 • • 發佈:2018-12-10
- 使用FlashFXP上傳jdk到CentOS,檔案位置如圖所示:
- 進入jdk所在的資料夾:
[[email protected] ~]# cd /usr/java/
- 檢視資料夾下的檔案:
[[email protected] java]# ls jdk-8u181-linux-x64.tar.gz
- 解壓jdk:
tar -zxvf jdk-8u181-linux-x64.tar.gz
- 檢視解壓後的資料夾:
[[email protected] java]# ls jdk1.8.0_181 jdk-8u181-linux-x64.tar.gz
- 開啟環境配置檔案:
[[email protected] java]# vim /etc/profile -bash: vim: command not found
說明沒有安裝vim,安裝vim命令為:
[[email protected] java]# yum -y install vim
再次開啟環境配置檔案,下最下面新增以下程式碼:
#set java jdk1.8.0_181 environment JAVA_HOME=/usr/java/jdk1.8.0_181 JRE_HOME=/usr/java/jdk1.8.0_181/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH export JAVA_HOME JRE_HOME CLASS_PATH PATH
/usr/java/jdk1.8.0_181是剛才解壓jdk1.8的路徑。
- 重新整理一下:
測試是否安裝成功:source /etc/profile
-
[[email protected] java]# java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
- 檢視jdk安裝位置:whereis命令:
which命令:[
java相關命令:[[email protected] ~]# which java /usr/java/jdk1.8.0_181/bin/java
[[email protected] ~]# java -verbose ... [Loaded java.lang.Shutdown from /usr/java/jdk1.8.0_181/jre/lib/rt.jar] [Loaded java.lang.Shutdown$Lock from /usr/java/jdk1.8.0_181/jre/lib/rt.jar]
- java相關命令:
[[email protected] ~]# java Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -server to select the "server" VM The default VM is server, because you are running on a server-class machine. -cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version:<value> Warning: this feature is deprecated and will be removed in a future release. require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search Warning: this feature is deprecated and will be removed in a future release. include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions with specified granularity -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument -splash:<imagepath> show splash screen with specified image See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.