CentOS7中的安装与配置Java Jdk 1.8
2017-11-14 15:30
706 查看
一、前期准备
环境:最小安装的CentOS 7(虚拟机安装的新版的centos系统,与6有一些配置文件上的差异),提前装好了lrssz工具(不会安装的,可以参看我的另一篇随笔——lrssz的安装)。
a) 首先从官网上下载Jdk 8 for Linux x64到window下。
b) 我这边用的最小安装,所以没有安装centos自带的openjdk,如果你安装时,不是最小安装的话,可能集成了系统的openjdk,所以我们先要删除自带的openjdk,具体步骤如下:
1) 在系统终端输入:
2) 删除openjdk,在终端输入:
注意:上面这两步可以一次性完成,而且很简单哦!
二、Jdk的安装
a) 我们登录超级用户,在超级用户目录root下建立一个目录app:
2
3
b) 我们进入app,将下载好的jdk压缩包导入centos:
rz #使用rz命令将jdk压缩包从window导入centos当下目录app中
c) 解压jdk压缩包
d) 解压后的jdk的文件夹名字为jdk1.8.0_45,我们把它改为jdk1.8:
e) 进入jdk文件夹,获取目录绝对路径(我的绝对路径是:/root/app/jdk1.8):
2
3
三、jdk的配置
a) 使用vim命令打开系统的环境变量配置文件:
b) 在profile文件最后加入:
2
3
4
5
c)重启机器
四、配置验证
a) 首先,我们输入java –version,会得到:
2
3
4
5
出现权限问题,则执行添加权限的命令:如
2
3
4
5
b) 我们再输入javac,会得出:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
c) 如果得到以上两步正确结果的话,恭喜你,你的jdk8就已经配置好了。
环境:最小安装的CentOS 7(虚拟机安装的新版的centos系统,与6有一些配置文件上的差异),提前装好了lrssz工具(不会安装的,可以参看我的另一篇随笔——lrssz的安装)。
a) 首先从官网上下载Jdk 8 for Linux x64到window下。
b) 我这边用的最小安装,所以没有安装centos自带的openjdk,如果你安装时,不是最小安装的话,可能集成了系统的openjdk,所以我们先要删除自带的openjdk,具体步骤如下:
1) 在系统终端输入:
rpm -qa | grep java,如果有openjdk的话,会出现类似于XXXX_openjdk_XXX的信息
2) 删除openjdk,在终端输入:
rpm -e –-nodeps XXXX_openjdk_XXX。即可删除自带的openjdk。
注意:上面这两步可以一次性完成,而且很简单哦!
rpm -e --nodeps `rpm -qa | grep java`1
二、Jdk的安装
a) 我们登录超级用户,在超级用户目录root下建立一个目录app:
su root #然后输入密码 mkdir app1
2
3
b) 我们进入app,将下载好的jdk压缩包导入centos:
cd app1
rz #使用rz命令将jdk压缩包从window导入centos当下目录app中
c) 解压jdk压缩包
tar –zxvf jdk-8u45-linux-x64.gz1
d) 解压后的jdk的文件夹名字为jdk1.8.0_45,我们把它改为jdk1.8:
mv jdk1.8.0_45/ jdk1.8/1
e) 进入jdk文件夹,获取目录绝对路径(我的绝对路径是:/root/app/jdk1.8):
cd jdk1.8 pwd1
2
3
三、jdk的配置
a) 使用vim命令打开系统的环境变量配置文件:
vi /etc/profile1
b) 在profile文件最后加入:
## JAVA export JAVA_HOME=/root/app/jdk1.8 #jdk的绝对路径(我的是:/root/app/jdk1.8) CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOME/bin export PATH JAVA_HOME CLASSPATH1
2
3
4
5
c)重启机器
sudo shutdown -r now或执行命令
source /etc/profile
四、配置验证
a) 首先,我们输入java –version,会得到:
java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)1
2
3
4
5
出现权限问题,则执行添加权限的命令:如
[root@iZcdqgn6qpldn9Z www]# java -version -bash: /root/app/jdk1.8/bin/java: Permission denied 添加权限命令 chmod 775 /root/app/jdk1.8/bin/java1
2
3
4
5
b) 我们再输入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 file1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
c) 如果得到以上两步正确结果的话,恭喜你,你的jdk8就已经配置好了。
相关文章推荐
- CentOS7中的安装与配置Java Jdk 1.8
- Java开发环境jdk 1.8安装配置方法(Win7 64位系统/windows server 2008)
- CentOS7安装javaJdk1.8、部署多台tomcat
- Linux安装jdk1.8配置后java命令不能用,提示权限不够
- CentOS7安装Java JDK 1.8
- 【解决】CentOS7 安装 jkd1.8 报错-bash: /usr/local/jdk1.8.0_121/bin/java: /lib/ld-linux.so.2: bad ELF interpr
- centos7安装、配置、卸载jdk1.8
- Ubuntu16.04安装JavaJDK1.8环境配置
- JAVA环境变量配置详细步骤和JDK1.8详细安装步骤
- CentOS6.5之Java开发环境—JDK1.8的安装配置—逆袭必备
- Centos7.3安装和配置Java JDK 1.8
- Ubuntu 16.04 安装配置Java jdk1.8
- Linux下(CentOS7)安装与配置JDK1.8(解压安装方式)
- Jdk1.8在CentOS7中的安装与配置
- centOS7安装并配置jdk1.8
- java JDK1.8安装与环境配置
- Linux下Java环境的安装和配置 (CentOS+JDK1.5.0_11)
- ubuntu下安装JDK并配置java环境
- ubuntu下安装JDK并配置java环境
- Linux(Fedora 14)下 java开发环境配置 ――jdk的安装与配置