开源中文网

您的位置: 首页 > Debian Linux > 正文

Debian8 (Jessie)安装配置java环境步骤

来源: 网络整理  作者: 佚名

配置java环境小编觉得比php环境要简单不知道是不是小编觉得apache或nginx太麻烦了,下面来为各位介绍Debian8 (Jessie)安装配置java环境步骤,有兴趣的来看看.

系统是 Debian8, Jessie, 默认java版本是:OpenJDK 1.7
1. 检查当前系统的java版本
leung@phychion:~$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-4)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
2. 配置安装java:
leung@phychion:~/Downloads$ tar zxf jdk-7u67-linux-x64.tar.gz
leung@phychion:~/Downloads$ sudo mv jdk1.7.0_67 /usr/lib/jvm/
3. 编辑/etc/profile,添加环境变量:
leung@phychion:~/Downloads$ sudo vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
4. 使用环境变量生效,不必重新登录shell:
leung@phychion:~/Downloads$ source /etc/profile
5. 配置JDK1.7的java,javac工具:
leung@phychion:~$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_67/bin/java 300
leung@phychion:~$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_67/bin/javac 300
update-alternatives: using /usr/lib/jvm/jdk1.7.0_67/bin/javac to provide /usr/bin/javac (javac) in auto mode
6. 设置系统默认的java版本,这里选择2:
leung@phychion:~$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/jdk1.7.0_67/bin/java                300       manual mode
Press enter to keep the current choice[*], or type selection number: 2          
update-alternatives: using /usr/lib/jvm/jdk1.7.0_67/bin/java to provide /usr/bin/java (java) in manual mode
leung@phychion:~$ sudo update-alternatives --config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /usr/lib/jvm/jdk1.7.0_67/bin/javac
Nothing to configure.
7. 确认设置的java版本:

leung@phychion:~$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Tags:步骤 环境
关于开源中文网 - 联系我们 - 广告服务 - 网站地图 - 版权声明