Java 如何在centos中安装Jdk

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20901442/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:09:27  来源:igfitidea点击:

How to install Jdk in centos

javacentos

提问by NavinRaj Pandey

I am new to centos and linux systems. I have downloaded both jdk-6u35-linux-x64.bin and .rpm.bin but neither of them is giving me .rpm file to install nor .bin is executing by itself

我是centos和linux系统的新手。我已经下载了 jdk-6u35-linux-x64.bin 和 .rpm.bin 但它们都没有给我 .rpm 文件来安装,也没有 .bin 自己执行

i have tried commands like ./ jdk..... .bin and gunzip for .tar files

我已经尝试过像 ./ jdk ..... .bin 和 gunzip 这样的命令来处理 .tar 文件

Can anyone kindly tell me few steps to install jdk1.6 in centos 6.5(Final) 64 bit machine with suitable download link

谁能告诉我在centos 6.5(Final) 64位机器上安装jdk1.6的几个步骤,并提供合适的下载链接

采纳答案by Destroyica

I advise you to use the same JDK as you may use with Windows: the Oracle one.

我建议您使用与 Windows 相同的 JDK:Oracle 一个。

http://www.oracle.com/technetwork/java/javase/downloads/index.html
Go to the Java SE 7u67section and click on JDK7 Download button on the right.

http://www.oracle.com/technetwork/java/javase/downloads/index.html
转到Java SE 7u67部分并单击右侧的 JDK7 下载按钮。

On the new page select the option "(¤) Accept License Agreement"
Then click on jdk-7u67-linux-x64.rpm

在新页面选择“ (¤)Accept License Agreement”选项,
然后点击jdk-7u67-linux-x64.rpm

On your CentOS, as root, run:

在您的 CentOS 上,以 root 身份运行:

$ rpm -Uvh jdk-7u67-linux-x64.rpm
$ alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2

You may already have a Java 5 installed on your box... beforeinstalling the downloaded rpm remove previous Java by running this command yum remove java

您可能已经在您的机器上安装了 Java 5...安装下载的 rpm 之前,通过运行此命令删除以前的 Javayum remove java

回答by Ezzored

Try the following to see if you have the proper repository installed:

尝试以下操作,看看您是否安装了正确的存储库:

# yum search java | grep 'java-'

This is going to return a list of available packages that have java in the title. Specifically we are interested in the java- anything, as the jdk will typically be in 'java-version#' type format... Anyhow, if you have to install a repo look at Dag Wieers repo:

这将返回标题中包含 java 的可用包列表。具体来说,我们对 java-anything 感兴趣,因为 jdk 通常采用 'java-version#' 类型格式...无论如何,如果您必须安装 repo,请查看 Dag Wieers repo:

http://dag.wieers.com/rpm/FAQ.php#B

http://dag.wieers.com/rpm/FAQ.php#B

After you've got it installed try yum search again... This time you'll have a bunch of java stuff.

安装好后,再次尝试 yum search... 这次你将拥有一堆 java 的东西。

# yum search java | grep 'java-'

This will return the list of the available java packages. You can install one like this:

这将返回可用 java 包的列表。您可以像这样安装一个:

# yum install java-1.7.0-openjdk.x86_64

回答by Gerard Ryan

There are JDK versions available from the base CentOS repositories. Depending on your version of CentOS, and the JDK you want to install, the following as root should give you what you want:

基本 CentOS 存储库中提供了 JDK 版本。根据您的 CentOS 版本和您要安装的 JDK,以 root 身份执行以下命令应该可以满足您的需求:

OpenJDK Runtime Environment (Java SE 6)

OpenJDK 运行时环境 (Java SE 6)

yum install java-1.6.0-openjdk

OpenJDK Runtime Environment (Java SE 7)

OpenJDK 运行时环境 (Java SE 7)

yum install java-1.7.0-openjdk

OpenJDK Development Environment (Java SE 7)

OpenJDK 开发环境(Java SE 7)

yum install java-1.7.0-openjdk-devel

OpenJDK Development Environment (Java SE 6)

OpenJDK 开发环境(Java SE 6)

yum install java-1.6.0-openjdk-devel


Update for Java 8

Java 8 更新

In CentOS 6.6 or later, Java 8 is available. Similar to 6 and 7 above, the packages are as follows:

在 CentOS 6.6 或更高版本中,Java 8 可用。与上面的6和7类似,包如下:

OpenJDK Runtime Environment (Java SE 8)

OpenJDK 运行时环境 (Java SE 8)

yum install java-1.8.0-openjdk

OpenJDK Development Environment (Java SE 8)

OpenJDK 开发环境(Java SE 8)

yum install java-1.8.0-openjdk-devel

There's also a 'headless' JRE package that is the same as the above JRE, except it doesn't contain audio/video support. This can be used for a slightly more minimal installation:

还有一个与上述 JRE 相同的“无头”JRE 包,只是它不包含音频/视频支持。这可以用于稍微更小的安装:

OpenJDK Runtime Environment - Headless (Java SE 8)

OpenJDK 运行时环境 - Headless (Java SE 8)

yum install java-1.8.0-openjdk-headless

回答by rawbean

Here is something that might help. Use the root privileges. if you have .bin then simply add the execution permission to the bin file.

这里有一些可能有帮助的东西。使用 root 权限。如果您有 .bin 则只需将执行权限添加到 bin 文件。

chmod a+x jdk*.bin

chmod a+x jdk*.bin

next step is to run the .bin file which is simply

下一步是运行 .bin 文件,它很简单

./jdk*.bin in the location you want to install.

./jdk*.bin 在您要安装的位置。

you are done.

你完成了。