ubuntu 14.04 安装 openjdk7

阅读更多
安装openjdk7之后,发现

输入java,提示
java
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install

发现bin目录下面并没有java这个文件,根据提示执行
sudo apt-get install openjdk-7-jre-headless
结果提示:
sudo apt-get install openjdk-7-jre-headless

Reading package lists... Done
Building dependency tree      
Reading state information... Done
openjdk-7-jre-headless is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
已经安装了?看来是包有问题,尝试下面的命令,结果还卸载不掉
sudo apt-get autoremove openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libosgi-compendium-java : Depends: libgeronimo-jpa-2.0-spec-java but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

然后尝试执行,发现也是已安装状态
sudo apt-get install libosgi-compendium-java
Reading package lists... Done
Building dependency tree      
Reading state information... Done
libosgi-compendium-java is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.

经过一番搜索,最后通过purge解决问题:
:~$ sudo apt-get purge openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libosgi-compendium-java : Depends: libgeronimo-jpa-2.0-spec-java but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

之后
sudo apt-get purge libosgi-compendium-java
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages will be REMOVED:
  libfelix-gogo-command-java* libfelix-gogo-runtime-java*
  libfelix-gogo-shell-java* libgeronimo-jpa-2.0-spec-java*
  libgeronimo-osgi-support-java* libosgi-compendium-java*
0 upgraded, 0 newly installed, 6 to remove and 20 not upgraded.
After this operation, 1,111 kB disk space will be freed.
Do you want to continue? [Y/n] Y

最后
~$ sudo apt-get purge openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following package was automatically installed and is no longer required:
  libservlet2.5-java
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  ant* ant-optional* aspectj* ca-certificates-java* default-jre*
  default-jre-headless* junit4* libatk-wrapper-java* libatk-wrapper-java-jni*
  openjdk-7-jdk* openjdk-7-jre* openjdk-7-jre-headless*
0 upgraded, 0 newly installed, 12 to remove and 20 not upgraded.
After this operation, 83.1 MB disk space will be freed.
Do you want to continue? [Y/n] Y


执行完purge之后,重新安装
sudo apt-get install openjdk-7-jre-headless
安装完之后java命令可以执行,且在/etc/alternatives目录下已经生成了java的软链接:
#cd /etc/alternatives
#ll java*
lrwxrwxrwx 1 root root 46 Dec 11 16:03 java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java*
lrwxrwxrwx 1 root root 56 Dec 11 16:03 java.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz

之后输入javac命令,
javac
The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.8-jdk
* openjdk-7-jdk
* gcj-4.6-jdk
* openjdk-6-jdk
Try: sudo apt-get install

接下来安装openjdk-7-jdk
#sudo apt-get install openjdk-7-jdk

安装完之后,软链接也被更新:
/etc/alternatives# ll java*
lrwxrwxrwx 1 root root 46 Dec 11 16:03 java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java*
lrwxrwxrwx 1 root root 56 Dec 11 16:03 java.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
lrwxrwxrwx 1 root root 43 Dec 11 16:07 javac -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javac*
lrwxrwxrwx 1 root root 53 Dec 11 16:07 javac.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javac.1.gz
lrwxrwxrwx 1 root root 45 Dec 11 16:07 javadoc -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc*
lrwxrwxrwx 1 root root 55 Dec 11 16:07 javadoc.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javadoc.1.gz
lrwxrwxrwx 1 root root 43 Dec 11 16:07 javah -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javah*
lrwxrwxrwx 1 root root 53 Dec 11 16:07 javah.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javah.1.gz
lrwxrwxrwx 1 root root 43 Dec 11 16:07 javap -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javap*
lrwxrwxrwx 1 root root 53 Dec 11 16:07 javap.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javap.1.gz

同样/usr/bin目录下的软链接也被更新:
/usr/bin$ ll java*
lrwxrwxrwx 1 root root 22 Dec 11 16:03 java -> /etc/alternatives/java*
lrwxrwxrwx 1 root root 23 Dec 11 16:07 javac -> /etc/alternatives/javac*
lrwxrwxrwx 1 root root 25 Dec 11 16:07 javadoc -> /etc/alternatives/javadoc*
lrwxrwxrwx 1 root root 23 Dec 11 16:07 javah -> /etc/alternatives/javah*
lrwxrwxrwx 1 root root 23 Dec 11 16:07 javap -> /etc/alternatives/javap*

至此安装完成

你可能感兴趣的:(ubuntu 14.04 安装 openjdk7)