Java 无法使用 yum 或 rpm 在 Fedora 上安装 jdk
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16246615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't install jdk on Fedora with yum nor with rpm
提问by Katie
Help! I can't figure out how to install a jdk!
帮助!我不知道如何安装jdk!
[/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.7.0-openjdk-devel available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.7.0-openjdk available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.6.0-openjdk-devel available.
Error: Nothing to do
[/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk"
Loaded plugins: langpacks, presto, refresh-packagekit
No package java-1.6.0-openjdk available.
Error: Nothing to do
Here I've manually downloaded some rpm's, the last one from oracle's website:
在这里,我手动下载了一些 rpm,最后一个来自 oracle 的网站:
[~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm
error: Failed dependencies:
java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64
[~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm
Preparing... ################################# [100%]
file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64
file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64
[~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm
Preparing... ################################# [100%]
file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64
Debug
调试
Here's some debug information:
以下是一些调试信息:
[/usr/lib/jvm]$ yum search jdk
Loaded plugins: langpacks, presto, refresh-packagekit
=========================================================== N/S Matched: jdk ============================================================
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit
ldapjdk.noarch : The Mozilla LDAP Java SDK
Name and summary matches only, use "search all" for everything.
.
.
[/usr/lib/jvm]$ yum list java*
Loaded plugins: langpacks, presto, refresh-packagekit
Installed Packages
java-1.5.0-gcj.x86_64
.
.
[/usr/lib/jvm]$ cat /etc/fedora-release
Fedora release 18 (Spherical Cow)
Requirements
要求
I musthave "jni.h", "libjava.so", "libhpi.so", "lipverify.so" and "libjvm.so" included.
我必须包含“ jni.h”、“ libjava.so”、“ libhpi.so”、“ lipverify.so”和“ libjvm.so”。
So far I've found out that these DO NOT have what I need:
到目前为止,我发现这些没有我需要的:
- Undesired Versions (for sure):
- jdk1.7.0_06 <-- I'm surprised about this one, but it doesn't have libjvm nor libhpi
- java-1.7.0
- java-openjdk
- java-1.7.0-openjdk-1.7.0.9.x86_64
- java-1.5.0-gcj-4.4
- java-1.6.0-openjdk
- java-1.7.0-openjdk.x86_64
- jre-1.5.0-gcj
- jre-1.7.0-openjdk.x86_64
- jre-openjdk
- jre-1.7.0
- jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0
- jre-1.5.0
- jre1.7.0_11
- jre-gcj
- 不需要的版本(当然):
- jdk1.7.0_06 <--我对这个很惊讶,但它没有 libjvm 和 libhpi
- java-1.7.0
- java-openjdk
- java-1.7.0-openjdk-1.7.0.9.x86_64
- java-1.5.0-gcj-4.4
- java-1.6.0-openjdk
- java-1.7.0-openjdk.x86_64
- jre-1.5.0-gcj
- jre-1.7.0-openjdk.x86_64
- jre-openjdk
- jre-1.7.0
- jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0
- jre-1.5.0
- jre1.7.0_11
- jre-gcj
And these do:
这些是:
- Desired Versions (that I know of, there could be more):
- jdk1.6.0_34-x86
- jdk1.5.0_22-x86
- java-6-openjdk
- 所需版本(据我所知,可能还有更多):
- jdk1.6.0_34-x86
- jdk1.5.0_22-x86
- java-6-openjdk
Can someone help me install jdk1.6 or java-6-openjdk please?
有人可以帮我安装 jdk1.6 或 java-6-openjdk 吗?
采纳答案by Kevin Cross
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the /etc/init.d/jexec
script which is already installed and required for JDK 6.
这里的问题是,当您已经拥有 Oracle JDK 6 时,您无法使用 Oracle rpm 安装 JDK 7,因为它会尝试安装/etc/init.d/jexec
已安装且 JDK 6 所需的脚本。
I would advise sticking to the tarball or self extracting *.bin
and using JAVA_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need jexecanyway.
*.bin
如果您打算使用 Oracle 发行版,我建议坚持使用 tarball 或自解压并使用 JAVA_HOME,因为它没有这个问题,而且您可能无论如何都不需要jexec。
回答by jbx
In general I would suggest that you install the Oracle JDK not the OpenJDK. Otherwise you might risk running into some issues. I always found problems of all sorts and sizes with OpenJDK that I don't even bother trying it any more.
一般来说,我建议您安装 Oracle JDK 而不是 OpenJDK。否则,您可能会遇到一些问题。我总是在使用 OpenJDK 时发现各种类型和大小的问题,我什至不再费心去尝试了。
Download the JDK RPM from hereand follow the usual instructions. Its usually very straightforward and without problems.
从这里下载 JDK RPM并按照通常的说明进行操作。它通常非常简单,没有问题。
Full detailed instructions including how to install it here.
完整的详细说明,包括如何在此处安装。
Make sure you choose the right version you need (JDK 1.7 or JDK 1.6, dont mix) because from your question you seem to have a confusion of library versions from 1.5 to 1.7.
确保您选择了您需要的正确版本(JDK 1.7 或 JDK 1.6,不要混用),因为从您的问题来看,您似乎混淆了从 1.5 到 1.7 的库版本。
And another thing, uninstall whatever you have installed already before installing a fresh one to avoid conflicts.
另一件事,在安装新的之前卸载您已经安装的任何东西以避免冲突。
回答by Calapacho
Check my answer here Transaction check error when installing Sun JDK 7
在此处检查我的答案安装 Sun JDK 7 时事务检查错误
Basically you may use rpm --force to install one JDK on top of the other. This scenario is completely valid specially when you have to develop for different JAVA versions.
基本上,您可以使用 rpm --force 将一个 JDK 安装在另一个之上。这种场景是完全有效的,特别是当你需要针对不同的 JAVA 版本进行开发时。
回答by Mike T
Just faced the same issue. I was not comfortable using --force command; did not want to risk messing-up the existing Java that came installed at system setup.
刚刚面临同样的问题。我不习惯使用 --force 命令;不想冒险弄乱系统设置时安装的现有 Java。
I ended up doing the following and running the app server with a different version of Java under a different user ID.
我最终执行了以下操作,并在不同的用户 ID 下使用不同版本的 Java 运行应用服务器。
downloaded the Java tar.gz version and uncompressed:
下载 Java tar.gz 版本并解压:
tar -zxvf jdk-7u45-linux-x64.gz
Created the directory:
创建目录:
mkdir /usr/java/jdk1.7.0_45
Copied the contents to the new directory manually:
手动将内容复制到新目录:
cp -r /.../jdk1.7.0_45/* /usr/java/jdk1.7.0_45
Set the java_home under the user ID home directory in .bashrc and .bash_profile files:
在 .bashrc 和 .bash_profile 文件中设置用户 ID 主目录下的 java_home:
export JAVA_HOME=/usr/java/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:/usr/sfw/lib/gcc:/usr/sfw/bin