博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu12.04 安装JDK7
阅读量:6647 次
发布时间:2019-06-25

本文共 9072 字,大约阅读时间需要 30 分钟。

1、通过apt-get直接下载安装JDK

sudo apt-get install openjdk-7-jdk

执行之后会将JDK安装到/usr/lib/jvm/java-7-openjdk-i386/

2、通过update-alternatives选择系统中使用的java

sudo update-alternatives --config java有 3 个候选项可用于替换 java (提供 /usr/bin/java)。  选择       路径                                         优先级  状态------------------------------------------------------------* 0            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      自动模式            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      手动模式            /usr/lib/jvm/java-6-sun/jre/bin/java            63        手动模式            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      手动模式要维持当前值[*]请按回车键,或者键入选择的编号:3       update-alternatives: 使用 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 来提供 /usr/bin/java (java),于 手动模式 中。

实际是将/usr/bin/java链接到JDK7上,保证执行java命令后,实际运行的是我们的目标版本

java -versionjava version "1.7.0_09"OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.04.1)OpenJDK Server VM (build 23.2-b09, mixed mode)

除了java外,还有javac、jar、javah、javap、jps、jconsole等

sudo update-alternatives --config javacsudo update-alternatives --config jar sudo update-alternatives --config javah sudo update-alternatives --config javap sudo update-alternatives --config jps sudo update-alternatives --config jconsole

补充:jps -lv  用于查看java程序的启动参数,如java版本

二、全手动

1、访问,下载jdk7

oracle没有提供deb的安装包,只能下载压缩包jdk-7u10-linux-i586.tar.gz

2、下载完成后,命令解压到/usr/lib/jvm

sudo tar zxvf ./jdk-7u10-linux-i586.tar.gz  -C /usr/lib/jvm

3、为JDK目录创建软连接到java-7-sun

sudo ln -s jdk1.7.0_10 java-7-sun

 

4、将javac、jar、javah、javap等添加到候选列表

sudo update-alternatives --install /usr/bin/ControlPanel ControlPanel /usr/lib/jvm/java-7-sun/jre/bin/ControlPanel 300sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/jre/bin/java 300sudo update-alternatives --install /usr/bin/java_vm java_vm /usr/lib/jvm/java-7-sun/jre/bin/java_vm 300sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/java-7-sun/jre/bin/javaws 300sudo update-alternatives --install /usr/bin/jcontrol jcontrol /usr/lib/jvm/java-7-sun/jre/bin/jcontrol 300sudo update-alternatives --install /usr/bin/keytool keytool /usr/lib/jvm/java-7-sun/jre/bin/keytool 300sudo update-alternatives --install /usr/bin/pack200 pack200 /usr/lib/jvm/java-7-sun/jre/bin/pack200 300sudo update-alternatives --install /usr/bin/policytool policytool /usr/lib/jvm/java-7-sun/jre/bin/policytool 300sudo update-alternatives --install /usr/bin/rmid rmid /usr/lib/jvm/java-7-sun/jre/bin/rmid 300sudo update-alternatives --install /usr/bin/rmiregistry rmiregistry /usr/lib/jvm/java-7-sun/jre/bin/rmiregistry 300sudo update-alternatives --install /usr/bin/unpack200 unpack200 /usr/lib/jvm/java-7-sun/jre/bin/unpack200 300sudo update-alternatives --install /usr/bin/orbd orbd /usr/lib/jvm/java-7-sun/jre/bin/orbd 300sudo update-alternatives --install /usr/bin/servertool servertool /usr/lib/jvm/java-7-sun/jre/bin/servertool 300sudo update-alternatives --install /usr/bin/tnameserv tnameserv /usr/lib/jvm/java-7-sun/jre/bin/tnameserv 300sudo update-alternatives --install /usr/bin/HtmlConverter HtmlConverter /usr/lib/jvm/java-7-sun/bin/HtmlConverter 300sudo update-alternatives --install /usr/bin/appletviewer appletviewer /usr/lib/jvm/java-7-sun/bin/appletviewer 300sudo update-alternatives --install /usr/bin/apt apt /usr/lib/jvm/java-7-sun/bin/apt 300sudo update-alternatives --install /usr/bin/extcheck extcheck /usr/lib/jvm/java-7-sun/bin/extcheck 300sudo update-alternatives --install /usr/bin/idlj idlj /usr/lib/jvm/java-7-sun/bin/idlj 300sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java-7-sun/bin/jar 300sudo update-alternatives --install /usr/bin/jarsigner jarsigner /usr/lib/jvm/java-7-sun/bin/jarsigner 300sudo update-alternatives --install /usr/bin/java-rmi.cgi java-rmi.cgi /usr/lib/jvm/java-7-sun/bin/java-rmi.cgi 300sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-sun/bin/javac 300sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/java-7-sun/bin/javadoc 300sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java-7-sun/bin/javah 300sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java-7-sun/bin/javap 300sudo update-alternatives --install /usr/bin/jconsole jconsole /usr/lib/jvm/java-7-sun/bin/jconsole 300sudo update-alternatives --install /usr/bin/jdb jdb /usr/lib/jvm/java-7-sun/bin/jdb 300sudo update-alternatives --install /usr/bin/jhat jhat /usr/lib/jvm/java-7-sun/bin/jhat 300sudo update-alternatives --install /usr/bin/jinfo jinfo /usr/lib/jvm/java-7-sun/bin/jinfo 300sudo update-alternatives --install /usr/bin/jmap jmap /usr/lib/jvm/java-7-sun/bin/jmap 300sudo update-alternatives --install /usr/bin/jps jps /usr/lib/jvm/java-7-sun/bin/jps 300sudo update-alternatives --install /usr/bin/jrunscript jrunscript /usr/lib/jvm/java-7-sun/bin/jrunscript 300sudo update-alternatives --install /usr/bin/jsadebugd jsadebugd /usr/lib/jvm/java-7-sun/bin/jsadebugd 300sudo update-alternatives --install /usr/bin/jstack jstack /usr/lib/jvm/java-7-sun/bin/jstack 300sudo update-alternatives --install /usr/bin/jstat jstat /usr/lib/jvm/java-7-sun/bin/jstat 300sudo update-alternatives --install /usr/bin/jstatd jstatd /usr/lib/jvm/java-7-sun/bin/jstatd 300sudo update-alternatives --install /usr/bin/native2ascii native2ascii /usr/lib/jvm/java-7-sun/bin/native2ascii 300sudo update-alternatives --install /usr/bin/rmic rmic /usr/lib/jvm/java-7-sun/bin/rmic 300sudo update-alternatives --install /usr/bin/schemagen schemagen /usr/lib/jvm/java-7-sun/bin/schemagen 300sudo update-alternatives --install /usr/bin/serialver serialver /usr/lib/jvm/java-7-sun/bin/serialver 300sudo update-alternatives --install /usr/bin/wsgen wsgen /usr/lib/jvm/java-7-sun/bin/wsgen 300sudo update-alternatives --install /usr/bin/wsimport wsimport /usr/lib/jvm/java-7-sun/bin/wsimport 300sudo update-alternatives --install /usr/bin/xjc xjc /usr/lib/jvm/java-7-sun/bin/xjc 300

5、创建/usr/lib/jvm/.java-7-sun.jinfo ,输入以下的内容

name=java-7-sun-1.7.0_10alias=java-7-sunpriority=63section=non-freejre ControlPanel /usr/lib/jvm/java-7-sun/jre/bin/ControlPaneljre java /usr/lib/jvm/java-7-sun/jre/bin/javajre java_vm /usr/lib/jvm/java-7-sun/jre/bin/java_vmjre javaws /usr/lib/jvm/java-7-sun/jre/bin/javawsjre jcontrol /usr/lib/jvm/java-7-sun/jre/bin/jcontroljre keytool /usr/lib/jvm/java-7-sun/jre/bin/keytooljre pack200 /usr/lib/jvm/java-7-sun/jre/bin/pack200jre policytool /usr/lib/jvm/java-7-sun/jre/bin/policytooljre rmid /usr/lib/jvm/java-7-sun/jre/bin/rmidjre rmiregistry /usr/lib/jvm/java-7-sun/jre/bin/rmiregistryjre unpack200 /usr/lib/jvm/java-7-sun/jre/bin/unpack200jre orbd /usr/lib/jvm/java-7-sun/jre/bin/orbdjre servertool /usr/lib/jvm/java-7-sun/jre/bin/servertooljre tnameserv /usr/lib/jvm/java-7-sun/jre/bin/tnameservjdk HtmlConverter /usr/lib/jvm/java-7-sun/bin/HtmlConverterjdk appletviewer /usr/lib/jvm/java-7-sun/bin/appletviewerjdk apt /usr/lib/jvm/java-7-sun/bin/aptjdk extcheck /usr/lib/jvm/java-7-sun/bin/extcheckjdk idlj /usr/lib/jvm/java-7-sun/bin/idljjdk jar /usr/lib/jvm/java-7-sun/bin/jarjdk jarsigner /usr/lib/jvm/java-7-sun/bin/jarsignerjdk java-rmi.cgi /usr/lib/jvm/java-7-sun/bin/java-rmi.cgijdk javac /usr/lib/jvm/java-7-sun/bin/javacjdk javadoc /usr/lib/jvm/java-7-sun/bin/javadocjdk javah /usr/lib/jvm/java-7-sun/bin/javahjdk javap /usr/lib/jvm/java-7-sun/bin/javapjdk jconsole /usr/lib/jvm/java-7-sun/bin/jconsolejdk jdb /usr/lib/jvm/java-7-sun/bin/jdbjdk jhat /usr/lib/jvm/java-7-sun/bin/jhatjdk jinfo /usr/lib/jvm/java-7-sun/bin/jinfojdk jmap /usr/lib/jvm/java-7-sun/bin/jmapjdk jps /usr/lib/jvm/java-7-sun/bin/jpsjdk jrunscript /usr/lib/jvm/java-7-sun/bin/jrunscriptjdk jsadebugd /usr/lib/jvm/java-7-sun/bin/jsadebugdjdk jstack /usr/lib/jvm/java-7-sun/bin/jstackjdk jstat /usr/lib/jvm/java-7-sun/bin/jstatjdk jstatd /usr/lib/jvm/java-7-sun/bin/jstatdjdk native2ascii /usr/lib/jvm/java-7-sun/bin/native2asciijdk rmic /usr/lib/jvm/java-7-sun/bin/rmicjdk schemagen /usr/lib/jvm/java-7-sun/bin/schemagenjdk serialver /usr/lib/jvm/java-7-sun/bin/serialverjdk wsgen /usr/lib/jvm/java-7-sun/bin/wsgenjdk wsimport /usr/lib/jvm/java-7-sun/bin/wsimportjdk xjc /usr/lib/jvm/java-7-sun/bin/xjcplugin xulrunner-addons-javaplugin.so /usr/lib/jvm/java-7-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so

说明,/usr/lib/jvm/.xxx.jinfo用于执行update-java-alternatives

 

6、执行update-java-alternatives

/usr/lib/jvm$ sudo update-java-alternatives -ljava-1.6.0-openjdk-i386 1061 /usr/lib/jvm/java-1.6.0-openjdk-i386java-1.7.0-openjdk-i386 1051 /usr/lib/jvm/java-1.7.0-openjdk-i386java-6-sun 63 /usr/lib/jvm/java-6-sunjava-7-sun 63 /usr/lib/jvm/java-7-sun/usr/lib/jvm$ sudo update-java-alternatives -s java-7-sunupdate-alternatives: 错误: 无 mozilla-javaplugin.so 的候选项。update-alternatives: 错误: 无 xulrunner-addons-javaplugin.so 的候选项。update-java-alternatives: jdk alternative does not exist: /usr/lib/jvm/java-7-sun/bin/HtmlConverterupdate-alternatives: 错误: wsgen 的候选项 /usr/lib/jvm/java-7-sun/bin/wsgen 没有注册,不予设置。update-alternatives: 错误: 无 xulrunner-addons-javaplugin.so 的候选项。

 

如果需要配置浏览器,可以参照oracle的文档:

 

转自:

转载地址:http://dduto.baihongyu.com/

你可能感兴趣的文章
带状态论文粗读(三)[引用openstate的相关论文阅读]
查看>>
pcDuino无显示器刷机与使用
查看>>
程序员出路在何方
查看>>
linux-alias基本用法
查看>>
compose函数
查看>>
Professional C# 6 and .NET Core 1.0 - Chapter 39 Windows Services
查看>>
C# 6 与 .NET Core 1.0 高级编程 - 40 ASP.NET Core(上)
查看>>
(已解决)Xcode 运行cocos2dx弹出内部错误对话框(Internal Error)
查看>>
J2EE 13规范(2)-JNDI
查看>>
模板维护-模板测试
查看>>
django -- 对模式进行调式(pay with the api)
查看>>
SQL Server sp_configure 控制内存使用
查看>>
通读《构建之法》提出问题
查看>>
VB生成xml
查看>>
左值、左值引用、右值、右值引用
查看>>
中转注入
查看>>
ACM 算法目录
查看>>
android 读取SD卡文件
查看>>
Flatten Binary Tree to Linked List
查看>>
Spring(十二)使用Spring的xml文件配置方式实现AOP
查看>>