Centos7下安裝Java Jdk1.8
阿新 • • 發佈:2018-12-09
一、下載jdk
二、用xftp上傳到Linux系統
你可以在root目錄下建立一個資料夾來存放該安裝包。
[[email protected] ~]# mkdir java_jdk
然後用xftp將安裝包上傳到該資料夾
三、在/usr/local下建立一個java目錄,用於將jdk安裝包解壓在裡面。
先轉到/usr/local目錄下,然後建立資料夾
[[email protected] java_jdk]# cd /usr/local
[[email protected] local]# mkdir java
轉到/root/java_jdk目錄下去解壓剛才上傳的安裝包
[[email protected] java]# cd /root/java_jdk
[[email protected] java_jdk]#
將安裝包解壓到安裝目錄/usr/local/java/目錄下
[[email protected] java_jdk]# tar -zxvf jdk-8u181-linux-x64.tar.gz -C /usr/local/java/
解壓完畢之後在/etc/profile檔案末尾新增下面這段程式碼
export JAVA_HOME=/usr/local/java/jdk1.8.0_101 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
首選用vim開啟檔案/etc/profile
[[email protected] java]# vim /etc/profile
按鍵盤i鍵可以進入輸入模式,將上面程式碼段複製到末端。按ESC鍵,退出輸入模式,按Shift鍵+ “ :”號鍵,輸入wq按回車鍵,儲存修改的檔案。如果不想儲存,則輸入q!按回車鍵退出不儲存。
使/etc/profile生效
[[email protected] java]# 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)
[ [email protected] java]# javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-parameters Generate metadata for reflection on method parameters
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-h <directory> Specify where to place generated native header files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-profile <profile> Check that API used is available in the specified profile
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-Werror Terminate compilation if warnings occur
@<filename> Read options and filenames from file
到此就安裝成功了!