无法在 UBUNTU 12.04 LTS 中安装/删除任何应用程序/包,错误:JAVA_HOME

无法在 UBUNTU 12.04 LTS 中安装/删除任何应用程序/包,错误:JAVA_HOME

这是“包操作失败窗口”中的错误:

installArchives() failed: Setting up install-info (4.13a.dfsg.1-8ubuntu2) ...
/etc/environment: line 3: JAVA_HOME: command not found
dpkg: error processing install-info (--configure):
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 install-info
Error in function: 
Setting up install-info (4.13a.dfsg.1-8ubuntu2) ...
/etc/environment: line 3: JAVA_HOME: command not found
dpkg: error processing install-info (--configure):
 subprocess installed post-installation script returned error exit status 127

这是我的 Ubuntu 中有关 Java 的信息。我不确定这些是否都设置正确。

update-java-alternatives -l 
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
java-1.7.0-openjdk-amd64 1051 /usr/lib/jvm/java-1.7.0-openjdk-amd64

java -version
java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.3)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64

如果我尝试升级,这是从终端复制并粘贴以下内容:

balu@balu-X550CC:~$ sudo apt-get upgrade
[sudo] password for balu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  duplicity linux-headers-generic linux-headers-generic-lts-raring
  linux-image-generic-lts-raring linux-signed-image-generic-lts-raring
The following packages will be upgraded:
  bluez bluez-alsa bluez-alsa:i386 bluez-cups bluez-gstreamer cups cups-bsd
  cups-client cups-common cups-ppdc curl deja-dup dpkg dpkg-dev firefox
  firefox-locale-en flashplugin-installer gir1.2-gdkpixbuf-2.0 gir1.2-gtk-2.0
  gir1.2-gtk-3.0 gnome-control-center gnome-control-center-data
  gnome-settings-daemon google-chrome-stable google-talkplugin
  icedtea-7-jre-jamvm libbluetooth3 libcups2 libcups2:i386 libcupscgi1
  libcupsdriver1 libcupsimage2 libcupsimage2:i386 libcupsmime1 libcupsppdc1
  libcurl3-gnutls libcurl3-nss libdpkg-perl libgail-3-0 libgdk-pixbuf2.0-0
  libgdk-pixbuf2.0-0:i386 libgdk-pixbuf2.0-common libgnome-control-center1
  libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-bin libgtk2.0-common
  libmysqlclient18 libmysqlclient18:i386 libnm-glib-vpn1 libnm-glib4
  libnm-util2 libsnmp-base libsnmp15 linux-firmware linux-generic-lts-raring
  linux-libc-dev linux-signed-generic-lts-raring linux-source
  linux-source-3.2.0 mysql-client-core-5.5 mysql-common mysql-server-core-5.5
  network-manager openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless
  openjdk-7-jre-lib python-imaging thunderbird thunderbird-globalmenu
  thunderbird-gnome-support thunderbird-locale-en thunderbird-locale-en-us
  unity-greeter update-manager update-manager-core whoopsie
79 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
1 not fully installed or removed.
Need to get 0 B/319 MB of archives.
After this operation, 16.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Extracting templates from packages: 100%
Preconfiguring packages ...
Setting up install-info (4.13a.dfsg.1-8ubuntu2) ...
/etc/environment: line 3: JAVA_HOME: command not found
dpkg: error processing install-info (--configure):
 subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 install-info

输出nano /etc/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

JAVA_HOME = ":usr/lib/jvm/java-7-openjdk-amd64/bin"
CLASSPATH = ":usr/lib/jvm/java-7-openjdk-amd64/bin:/home/something etc"

答案1

仔细阅读错误消息。它告诉您,/etc/environment子 shell 的第 3 行尝试执行命令JAVA_HOME,但失败了。您(或您的系统管理员)尝试将JAVA_HOMECLASSPATH变量的定义添加到/etc/environment,但输入错误。应该是:

JAVA_HOME="usr/lib/jvm/java-7-openjdk-amd64/bin"
CLASSPATH="usr/lib/jvm/java-7-openjdk-amd64/bin:/home/something etc"

(“=”两边没有空格,没有初始冒号(表示空条目。感谢@salarcot895)

相关内容