1.編譯安裝jdkjava
[root@localhost src]# mkdir /usr/java #建立存放目錄 [root@localhost src]# tar -zxvf jdk-8u131-linux-x64.tar.gz #解壓下載好的jdk [root@localhost src]# mv jdk1.8.0_131/ /usr/java #移動到建立的目錄
2.配置jdk環境linux
以root用戶,編輯系統全局環境配置文件/etc/profilevim
[root@localhost src]# vim /etc/profile 在/etc/profile文件尾部添加: export JAVA_HOME=/usr/java/jdk1.8.0_131 #jdk安裝路徑 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH.
[tomcat@localhost ~]$ vim .bash_profile #修改成下面的內容 # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs JAVA_HOME=/usr/java/jdk1.8.0_131 #jdk安裝路徑 export JAVA_HOME CLASSPATH=.:$JAVA_HOME/jre/lib/dt.jar:$JAVA_HOME/jre/lib/tools.jar export CLASSPATH PATH=$PATH:$HOME/bin:$JAVA_HOME/jre/bin export PATH export LANG=zh_CN.UTF-8 [tomcat@localhost ~]$ source /etc/profile [tomcat@localhost ~]$ java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)