29

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

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

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

NavinRaj Pandey
  • 1,674
  • 2
  • 26
  • 40
  • Same question as http://stackoverflow.com/questions/5104817/how-to-install-java-sdk-on-centos ? – UrMo Jan 03 '14 at 10:55
  • Possible duplicate of [How to install Java SDK on CentOS?](http://stackoverflow.com/questions/5104817/how-to-install-java-sdk-on-centos) – Dai Kaixian Mar 28 '17 at 10:59

4 Answers4

65

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:

OpenJDK Runtime Environment (Java SE 6)

yum install java-1.6.0-openjdk

OpenJDK Runtime Environment (Java SE 7)

yum install java-1.7.0-openjdk

OpenJDK Development Environment (Java SE 7)

yum install java-1.7.0-openjdk-devel

OpenJDK Development Environment (Java SE 6)

yum install java-1.6.0-openjdk-devel

Update for Java 8

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

OpenJDK Runtime Environment (Java SE 8)

yum install java-1.8.0-openjdk

OpenJDK Development Environment (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:

OpenJDK Runtime Environment - Headless (Java SE 8)

yum install java-1.8.0-openjdk-headless
grdryn
  • 1,972
  • 4
  • 19
  • 28
  • 1
    On CentOS 6.5 I had to run jum install java-1.7.0-openjdk java-1.7.0-openjdk-devel. Without both the jdk and jdk development kit it will not run from the startup shell script. – Lance Cleveland Aug 09 '14 at 16:01
  • yes yum install does intall open jdk but i have to run glassfish on the top of this jdk will this give any problem ... in fact i have not tried much but its not working now.. – NavinRaj Pandey Aug 14 '14 at 11:29
  • @NavinRajPandey that sounds like a different question, I'd recommend opening a new question for it. – grdryn Aug 14 '14 at 12:04
  • One has to be mindful of the `alternatives` for java-related commands other than the main `java` command. Perform `ls -l /etc/alternatives` and check. As far as I can recall (would have to remove then reinstall to double check) the `alternatives` were not all set to point to the new JDK8 for all utility commands until I also installed the `openjdk-devel` package. – Webel IT Australia - upvoter Sep 19 '16 at 01:55
38

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

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

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

On your CentOS, as root, run:

$ 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... before installing the downloaded rpm remove previous Java by running this command yum remove java

Destroyica
  • 4,147
  • 3
  • 33
  • 50
  • 1
    finally I have intalled the oracle java and glassfish is also doing fine on it .. will look forward to try open jdk as well @Destroyica thank you for remove command should have tried it earlier stuck me for long – NavinRaj Pandey Aug 15 '14 at 15:40
  • 1
    mine refused to install (saying it already was) until I did `rpm -e jdk` prior to trying again if that helps anyone – Hashbrown Dec 09 '14 at 06:23
  • 2
    The download can be completed from your shell:`wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm` before rpm. You can as well validate with `sudo alternatives --config java` if you have Java already installed and which version is active. And you may need to run `chmod a+x jdk-8u66-linux-x64.rpm` – Sergey V. Dec 07 '15 at 05:20
6

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:

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 | grep 'java-'

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

# yum install java-1.7.0-openjdk.x86_64
Ezzored
  • 905
  • 4
  • 10
2

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

chmod a+x jdk*.bin

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

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

you are done.

rawbean
  • 21
  • 1