Linux CentOS 6.9安装 jdk-9.0.4_linux-x64
2018-01-24 21:35
330 查看
Linux CentOS 6.9安装 jdk-9.0.4_linux-x64
目录
1、下载JDK
2、卸载JDK
3、安装JDK
3、.rpm后缀格式JDK安装方式
4、验证安装
1、下载JDK
根据操作系统的位数下载对应的JDK,操作系统是32位的就下32位的JDK,64位的就下64位的JDK。Linux x86是32位JDK,Linux x64是64位JDK。
Linux下的JDK安装包现有两种格式.rpm和.tar.gz。rpm是redhat红帽的标准安装包,rpm安装时会自动配置。
本安装示例在CentOS 6.6系统下进行,其它类型Linux系统安装方式相同,下载的JDK版本为jdk-9.0.4_linux-x64_bin.rpm,对.rpm和.tar.gz安装方式分别说明,本处已下载两种格式的文件。
jdk-9.0.4_linux-x64_bin.rpm
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html
2、卸载JDK
查看系统是否已安装JDK。一般的linux都默认使用了开源的openJDK。显示JDK版本信息,已经安装JDK,否则没有安装。命令行:
[plain] view
plain copy
java -version
[root@localhost ~]# java -version
java version "1.7.0_131"
OpenJDK Runtime Environment (rhel-2.6.9.0.el6_8-x86_64 u131-b00)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)
查找名字包含java,jdk的已安装程序。查找到了,已经安装JDK,否则没有安装。命令行:
[plain] view
plain copy
rpm -qa | grep java
rpm -qa | grep jdk
[root@localhost ~]# rpm -qa | grep java
tzdata-java-2016j-1.el6.noarch
java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el6_8.x86_64
[root@localhost ~]# rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el6_8.x86_64
已安装JDK,卸载系统上的JDK。
单个卸载程序,使用rpm -e xxx命令。命令行:
[plain] view
plain copy
rpm -e jdk-1.7.0_79-fcs.x86_64
[root@localhost Desktop]# rpm -e java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
批量卸载所有名字包含jdk的已安装程序。命令行:
[plain] view
plain copy
rpm -qa | grep jdk | xargs rpm -e --nodeps
[root@localhost Desktop]# rpm -qa | grep jdk | xargs rpm -e --nodeps
批量卸载所有名字包含java的已安装程序。命令行:
[plain] view
plain copy
rpm -qa | grep java | xargs rpm -e --nodeps
[root@localhost Desktop]# rpm -qa | grep java | xargs rpm -e --nodeps
卸载后,查看JDK版本,已无信息,卸载成功。命令行:
[plain] view
plain copy
java -version
[root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
安装jdk-9.0.4_linux-x64_bin.rpm。
给安装包添加权限。命令行:
[plain] view
plain copy
chmod 755 jdk-9.0.4_linux-x64_bin.rpm
[root@localhost Desktop]# chmod 755 jdk-9.0.4_linux-x64_bin.rpm
使用rpm -ivh xxx命令安装JDK。命令行:
[plain] view
plain copy
rpm -ivh jdk-9.0.4_linux-x64_bin.rpm
[root@localhost Desktop]# rpm -ivh jdk-9.0.4_linux-x64_bin.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
安装.rpm格式后缀的JDK不需要配置java环境变量,会自动配置,会在/usr/bin生成java、javac等JDK的快捷方式图标,这些图标会链接指向到/usr/java/jdk-9.0.4_linux-x64中。用echo $PATH查看环境变量,可以看到/usr/bin是加入了PATH环境变量中的。命令行:
[plain] view
plain copy
echo $PATH
[root@localhost Desktop]# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin
4、验证安装
安装完成后,查看JDK版本。命令行:
[plain] view
plain copy
java -version
测试下javac命令是否可用。命令行:
[plain] view
plain copy
javac
[root@localhost Desktop]# 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
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source 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
-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
还可以写段代码测试下。用VI编辑java代码测试JDK是否能正常编译。按Insert键进入编辑状态。命令行:
[plain] view
plain copy
vi test.java
[plain] view
plain copy
class test
{
public static void main(String[]args)
{
System.out.println("Hello World!");
}
}
[root@localhost Desktop]# vi test.java
class test
{
public static void main(String[]args)
{
System.out.println("Hello World!");
}
}
写好后,按Esc退出,按Shift加英文冒号shift + : 然后输入wq,按Enter回车键确认。
编译运行。命令行:
[plain] view
plain copy
javac test.java
[plain] view
plain copy
java test
[root@localhost Desktop]# javac test.java
[root@localhost Desktop]# java test
Hello World!
目录
1、下载JDK
2、卸载JDK
3、安装JDK
3、.rpm后缀格式JDK安装方式
4、验证安装
1、下载JDK
根据操作系统的位数下载对应的JDK,操作系统是32位的就下32位的JDK,64位的就下64位的JDK。Linux x86是32位JDK,Linux x64是64位JDK。
Linux下的JDK安装包现有两种格式.rpm和.tar.gz。rpm是redhat红帽的标准安装包,rpm安装时会自动配置。
本安装示例在CentOS 6.6系统下进行,其它类型Linux系统安装方式相同,下载的JDK版本为jdk-9.0.4_linux-x64_bin.rpm,对.rpm和.tar.gz安装方式分别说明,本处已下载两种格式的文件。
jdk-9.0.4_linux-x64_bin.rpm
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html
2、卸载JDK
查看系统是否已安装JDK。一般的linux都默认使用了开源的openJDK。显示JDK版本信息,已经安装JDK,否则没有安装。命令行:
[plain] view
plain copy
java -version
[root@localhost ~]# java -version
java version "1.7.0_131"
OpenJDK Runtime Environment (rhel-2.6.9.0.el6_8-x86_64 u131-b00)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)
查找名字包含java,jdk的已安装程序。查找到了,已经安装JDK,否则没有安装。命令行:
[plain] view
plain copy
rpm -qa | grep java
rpm -qa | grep jdk
[root@localhost ~]# rpm -qa | grep java
tzdata-java-2016j-1.el6.noarch
java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el6_8.x86_64
[root@localhost ~]# rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el6_8.x86_64
已安装JDK,卸载系统上的JDK。
单个卸载程序,使用rpm -e xxx命令。命令行:
[plain] view
plain copy
rpm -e jdk-1.7.0_79-fcs.x86_64
[root@localhost Desktop]# rpm -e java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
批量卸载所有名字包含jdk的已安装程序。命令行:
[plain] view
plain copy
rpm -qa | grep jdk | xargs rpm -e --nodeps
[root@localhost Desktop]# rpm -qa | grep jdk | xargs rpm -e --nodeps
批量卸载所有名字包含java的已安装程序。命令行:
[plain] view
plain copy
rpm -qa | grep java | xargs rpm -e --nodeps
[root@localhost Desktop]# rpm -qa | grep java | xargs rpm -e --nodeps
卸载后,查看JDK版本,已无信息,卸载成功。命令行:
[plain] view
plain copy
java -version
[root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
3、.rpm后缀格式JDK安装方式
安装jdk-9.0.4_linux-x64_bin.rpm。给安装包添加权限。命令行:
[plain] view
plain copy
chmod 755 jdk-9.0.4_linux-x64_bin.rpm
[root@localhost Desktop]# chmod 755 jdk-9.0.4_linux-x64_bin.rpm
使用rpm -ivh xxx命令安装JDK。命令行:
[plain] view
plain copy
rpm -ivh jdk-9.0.4_linux-x64_bin.rpm
[root@localhost Desktop]# rpm -ivh jdk-9.0.4_linux-x64_bin.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
安装.rpm格式后缀的JDK不需要配置java环境变量,会自动配置,会在/usr/bin生成java、javac等JDK的快捷方式图标,这些图标会链接指向到/usr/java/jdk-9.0.4_linux-x64中。用echo $PATH查看环境变量,可以看到/usr/bin是加入了PATH环境变量中的。命令行:
[plain] view
plain copy
echo $PATH
[root@localhost Desktop]# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin
4、验证安装
安装完成后,查看JDK版本。命令行:
[plain] view
plain copy
java -version
测试下javac命令是否可用。命令行:
[plain] view
plain copy
javac
[root@localhost Desktop]# 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
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source 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
-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
还可以写段代码测试下。用VI编辑java代码测试JDK是否能正常编译。按Insert键进入编辑状态。命令行:
[plain] view
plain copy
vi test.java
[plain] view
plain copy
class test
{
public static void main(String[]args)
{
System.out.println("Hello World!");
}
}
[root@localhost Desktop]# vi test.java
class test
{
public static void main(String[]args)
{
System.out.println("Hello World!");
}
}
写好后,按Esc退出,按Shift加英文冒号shift + : 然后输入wq,按Enter回车键确认。
编译运行。命令行:
[plain] view
plain copy
javac test.java
[plain] view
plain copy
java test
[root@localhost Desktop]# javac test.java
[root@localhost Desktop]# java test
Hello World!
相关文章推荐
- Unbuntu12.04 x64 安装jdk-7u45-linux-x64.tar.gz
- linux 6 安装jrockit-jdk1.6.0_29-R28.2.0-4.1.0-linux-x64
- Centos7安装jdk-8u144-linux-x64.r…
- Ubuntu12.04安装JDK(jdk-6u45-linux-x64.bin)(转载)
- CentOS7 安装jdk [64-bit]jdk-7u67-linux-x64.gz
- centos6.3安装 jdk-8u131-linux-x64.gz
- Ubuntu10.10 64位安装jdk-6u-linux-x64-rpm.bin和tomcat6.0.33
- linux CentOS6.5 x64系统下安装JDK1.7+tomcat7.0+nginx1.9.9
- linux下用rpm 安装jdk 7的jdk-7u79-linux-x64.rpm
- linux下下安装jdk-6u45-linux-x64.bin
- Unbuntu12.04 x64 安装jdk-7u45-linux-x64.tar.gz
- [odroid-pc] ubuntu12.04 安装jdk-6u45-linux-x64.bin
- ubuntu安装jdk-6u45-linux-x64-rpm.bin
- linux 64位操作系统安装jdk-6u35-linux-x64-rpm.bin
- Arch/Manjaro Linux 安装JDK-9.0.4-1
- linux CentOS release 6.7 (Final)_64中安装jdk-8u151-linux-x64
- Ubuntu 12.10下安装 jdk-7u10-linux-x64.tar.gz
- 在CentOS6上安装 jdk-7u79-linux-x64.gz
- RedHat Linux Server 5.4安装jdk-6u22-linux-x64-rpm.bin
- shell 脚本自动安装jdk-6u34-linux-x64-rpm.bin 跳过回车自动安装