我的 openjdk 出了问题,我清除它并重新安装它。
# apt-get remove --purge openjdk-7-jre
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
openjdk-7-jre*
0 upgraded, 0 newly installed, 1 to remove and 1128 not upgraded.
After this operation, 508 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 117956 files and directories currently installed.)
Removing openjdk-7-jre:i386 ...
update-alternatives: warning: alternative /usr/lib/jvm/java-6-openjdk-i386/jre/bin/policytool (part of link group policytool) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-7-openjdk-i386/jre/bin/policytool (part of link group policytool) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-8-oracle/jre/bin/policytool (part of link group policytool) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/policytool is dangling; it will be updated with best choice
Processing triggers for desktop-file-utils ...
Processing triggers for hicolor-icon-theme ...
root@localhost:/home/debian# apt-get install openjdk-7-jre
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
openjdk-7-jre
0 upgraded, 1 newly installed, 0 to remove and 1128 not upgraded.
Need to get 0 B/215 kB of archives.
After this operation, 508 kB of additional disk space will be used.
Selecting previously unselected package openjdk-7-jre:i386.
(Reading database ... 117932 files and directories currently installed.)
Unpacking openjdk-7-jre:i386 (from .../openjdk-7-jre_7u79-2.5.5-1~deb7u1_i386.deb) ...
update-alternatives: warning: alternative /usr/lib/jvm/java-8-oracle/jre/bin/javaws (part of link group javaws) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/javaws is dangling; it will be updated with best choice
Processing triggers for hicolor-icon-theme ...
Processing triggers for desktop-file-utils ...
Setting up openjdk-7-jre:i386 (7u79-2.5.5-1~deb7u1) ...
update-alternatives: using /usr/lib/jvm/java-7-openjdk-i386/jre/bin/policytool to provide /usr/bin/policytool (policytool) in auto mode
# java -version
bash: /usr/bin/java: No such file or directory
如何建立一个使用openjdk的链接?
root@localhost:/home/debian# locate java
/etc/.java
/etc/java-6-openjdk
/etc/javascript-common
/etc/.java/.systemPrefs
/etc/.java/.systemPrefs/.system.lock
/etc/alternatives/java
/etc/alternatives/java.1.gz
/etc/alternatives/javac
/etc/alternatives/javac.1.gz
/etc/alternatives/javadoc
/etc/alternatives/javadoc.1.gz
/etc/alternatives/javafxpackager
/etc/alternatives/javafxpackager.1.gz
/etc/alternatives/javah
/etc/alternatives/mozilla-javaplugin.so
/etc/apache2/conf.d/javascript-common.conf
/etc/java-6-openjdk/accessibility.properties
/etc/java-6-openjdk/calendars.properties
/etc/java-6-openjdk/content-types.properties
/etc/java-6-openjdk/flavormap.properties
/etc/java-6-openjdk/fontconfig.properties
/etc/java-6-openjdk/images
/etc/java-6-openjdk/jvm-i386.cfg
/etc/java-6-openjdk/logging.properties
/etc/java-6-openjdk/management
/etc/java-6-openjdk/net.properties
/etc/java-6-openjdk/psfont.properties.ja
/etc/java-6-openjdk/psfontj2d.properties
/etc/java-6-openjdk/security
/etc/java-6-openjdk/sound.properties
/etc/java-6-openjdk/swing.properties
/etc/java-6-openjdk/tz.properties
/etc/java-6-openjdk/images/cursors
/etc/java-6-openjdk/images/cursors/cursors.properties
/etc/java-6-openjdk/management/jmxremote.access
/etc/java-6-openjdk/management/jmxremote.password
/etc/java-6-openjdk/management/management.properties
/etc/java-6-openjdk/management/snmp.acl
/etc/java-6-openjdk/security/java.policy
/etc/java-6-openjdk/security/java.security
/etc/java-6-openjdk/security/nss.cfg
/etc/javascript-common/javascript-common.conf
/etc/ssl/certs/java
/home/debian/.java
/home/debian/.config/libreoffice/3/user/config/javasettings_Linux_x86.xml
/home/debian/.java/deployment
/home/debian/.java/fonts
/home/debian/.java/deployment/CacheUpgrade.properties
/home/debian/.java/deployment/cache
/home/debian/.java/deployment/config.cache
/home/debian/.java/deployment/deployment.propertie
root@localhost:/home/debian# 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.
openjdk-7-jre-headless set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 1128 not upgraded.
root@localhost:/home/debian# java -version
bash: java: command not found
root@localhost:/home/debian#
答案1
由于某种原因openjdk-7-jre
不包含java
可执行文件。openjdk-7-jre-headless
确实如此,但是如果您需要运行 GUI java 程序,那么这没有多大用处。
编辑:
安装无头软件包后:
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb 13 2012 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 May 23 2013 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
$ dpkg -S /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
openjdk-7-jre-headless:amd64: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
$ java -version # note, not "--version" but "-version"
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
因此,如果安装后您仍然没有可用的 /usr/bin/java ,那么在配置阶段就会出现问题。以 root 身份运行update-alternatives --config java
。
答案2
apt-get install openjdk-7-jre-headless
答案3
JRE: Java运行时环境。它基本上是运行 Java 程序的 Java 虚拟机。它还包括用于 Applet 执行的浏览器插件。
JDK:它是功能齐全的 Java 软件开发工具包,包括JRE,以及用于创建和编译程序的编译器和工具(如 JavaDoc 和 Java 调试器)。
因此,最好安装 jdk。为此,请输入以下命令:
sudo apt-get 安装 openjdk-7-jdk