You are on page 1of 14

 HOME UBUNTU 16.

04 FEEDBACK FUNNY TOOLS TUTORIALS SUBMIT ARTICLE ABOUT US

How to Install JAVA 8 on CentOS/RHEL  Search Now

7/6 and Fedora 28-23


Updated on May 3, 2018 by Rahul K.

 JAVA  java, java 8, Java_home, jdk, jdk-jre, jre, jre_home, openjdk, oracle java, sun java

This tutorial helps you to install Java 8 or update Java on your system. Read the instruction
carefully before downloading Java from Linux command line. To Install Java 8 in Ubuntu
and LinuxMint read This Article.

POPULAR POSTS

How to Install Docker on Ubuntu 18.04 & 16.04 LTS


Step 1 – Download Latest Java Archive
How to Install Python 3.7.0 on CentOS/RHEL 7/6 &
The Oracle team provides Java RPM packages as well as compiled source code. Many Fedora 28-23
times I have tried Java installation using rpm packages but I faced some issues. So I
How to Install Java 10 (18.03) on Ubuntu 18.04 &
decided to install Java using the compiled source code. Since then I have installed a large
16.04
number of times Java on CentOS, Redhat based systems without any issues. To download
the latest Java SE Development Kit 8 release from its official download page o r u s e How to Install and Use Cordova on Fedora 28-23

following commands to download from the shell.


How to Install MongoDB 4.0 on Fedora 28/27/26

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle
.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/
jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz"
# tar xzf jdk-8u171-linux-x64.tar.gz

Step 2 – Install Java 8 with Alternatives


The alternatives command is used for maintained symbolic links. This command used to
creates, removes, maintains and displays information about the symbolic links comprising
the alternatives system. Let’s use the alternatives command to configure Java on your
system. The alternatives command is available in chkconfig package.

# cd /opt/jdk1.8.0_171/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 2
# alternatives --config java

There are 3 programs which provide 'java'.

Selection Command
-----------------------------------------------
* 1 /opt/jdk1.7.0_71/bin/java
+ 2 /opt/jdk1.8.0_45/bin/java
3 /opt/jdk1.8.0_144/bin/java
4 /opt/jdk1.8.0_171/bin/java

Enter to keep the current selection[+], or type selection number: 4

At this point JAVA 8 has been successfully installed on your system. We also recommend
to setup javac and jar commands path using alternatives

# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_171/bin/jar 2


# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_171/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_171/bin/jar
# alternatives --set javac /opt/jdk1.8.0_171/bin/javac

Step 3 – Check Installed Java Version


Java and javac binaries are available under PATH environment variable. You can use them
from anywhere in your system. Let’s check the installed version of Java runtime
environment (JRE) on your system by executing the following command.

# java -version

java version "1.8.0_171"


Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Step 4 – Setup Java Environment Variables


Most of Java based application’s uses environment variables to work. Set the Java
environment variables using following commands

Set the JAVA_HOME, JRE_HOME and PATH environment variables.

# export JAVA_HOME=/opt/jdk1.8.0_171
# export JRE_HOME=/opt/jdk1.8.0_171/jre
# export PATH=$PATH:/opt/jdk1.8.0_171/bin:/opt/jdk1.8.0_171/jre/bin

Also add the above commands to /etc/bashrc file to auto set environment variables on
the system boot.

SHARE IT!     

RAHUL K.   
I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a
Red Hat Certified Engineer (RHCE) and working as an IT professional since
2009..

RELATED POSTS

How to Install Java 10 (18.03) on Debian 9/8 via PPA

How to Install Java 10 (18.03) on Ubuntu 18.04 & 16.04

How to Install Java 10 (18.03) on CentOS/RHEL 7/6, Fedora 28-23

Installing Java on Ubuntu

How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux Mint 19/18

118 COMMENTS

ANOOP  REPLY TO ANOOP


August 7, 2018 at 11:55 pm
Very helpful and clearly documented. Thanks Rahul

COLIN  REPLY TO COLIN


July 11, 2018 at 7:04 pm
I just wanted to add that this is very helpful for anyone using SAP Hybris. The system and its Apache Ant
builder are very sensitive to Java changes and build paths. Thank you for the content.

SAIKIRAN  REPLY TO SAIKIRAN


July 10, 2018 at 6:23 pm
nice expalnation its worked for me

VAM  REPLY TO VAM


July 6, 2018 at 5:01 am
nice article
tq

MIKE  REPLY TO MIKE


June 21, 2018 at 12:38 pm
Works like a charm, thank you Rahul!

STEVEN  REPLY TO STEVEN


June 8, 2018 at 10:07 pm
Fantastic article, thank you!

SHAHAMA  REPLY TO SHAHAMA


April 12, 2018 at 5:17 am
I’m getting below error when I try java -version command
-bash: /usr/bin/java: cannot execute binary file
Any Solutions?

RAHUL K.  REPLY TO RAHUL


April 13, 2018 at 6:23 am
Try:

chmod +x /opt/jdk1.8.0_161/bin/java

SHAHAMA  REPLY TO SHAHAMA


April 2, 2018 at 4:43 am
I need to upgrade my Oracle Java 1.7.0_79 to 1.8. Is this above method will work? or is there any other method?

RAHUL K.  REPLY TO RAHUL


April 2, 2018 at 6:39 am
Yes, it will work with Java upgrade also.

SHAHAMA  REPLY TO SHAHAMA


April 12, 2018 at 4:54 am
Thank you. It is working fine. This article is very helpful. Keep on Posting

JUNGHAN  REPLY TO JUNGHAN


March 26, 2018 at 5:08 am
Thank you. It helps a lot and working.

NEERAJ SHARMA  REPLY TO NEERAJ


March 11, 2018 at 12:31 pm
Hi Rahul,

I’ve following you for quite some time and I really appreciate your contribution. However I’ve never been able
to fathom how alternative command works.

Will you please enlighten me.

ABHISHEK  REPLY TO ABHISHEK


February 22, 2018 at 6:36 am
Please for god’s sake remove the /etc/environment update section…. that’s not correct and it screws up the
system

SRIPADA SARMA  REPLY TO SRIPADA


April 7, 2018 at 5:47 am
I followed it verbatim and later I saw your comment. Now it is not working and as good as
not installed. The .sh file is not running as exe program. Pl how to undo /etc/bashrc.

NOOR  REPLY TO NOOR


February 7, 2018 at 8:13 am
I followed above steps but unfortunately i cannot edit /etc/environment file now, due to change in this file i am
unable to run any command from my user even i cannot run sudo, sudo su or ls chown etc..
I am working on AWS Linux instance.
please help i can access files via ssh and winscp but with no permission to edit.

VICTO  REPLY TO VICTO


February 24, 2018 at 4:08 pm
Reboot from dvd with rescue option, then remove the lines in de environment file.

NOOR KHAN  REPLY TO NOOR


March 20, 2018 at 10:33 am
really VICTO ? how to do this on AWS linux instance? i am unable to see such
option on aws

ALEKSANDRK  REPLY TO ALEKSANDRK


February 1, 2018 at 8:30 am
Good tutorial. Thank you!

LUIS URZUA ARENAS  REPLY TO LUIS


January 31, 2018 at 6:23 pm
Thank you, very usefyll!

AMAR  REPLY TO AMAR


January 31, 2018 at 10:20 am
Thank you. saved lot of time

SD  REPLY TO SD
January 18, 2018 at 1:35 pm
Download Path incorrect

GIRI  REPLY TO GIRI


January 5, 2018 at 12:41 am
Even after following the instructions, the java version on my Centos is still at 1.7. I can see the folders for 1.8 are
created but ‘java -version’ still returns 1.7. Any reasons?

MADHUKAR REDDY  REPLY TO MADHUKAR


January 9, 2018 at 5:52 am
instructions messed up the root login PATH

subsequent root login gives these errors


Last login: Tue Jan 9 00:45:24 2018 from 116.74.251.1
bash: tty: command not found…
Similar command is: ‘tty’
bash: ls: command not found…
Similar command is: ‘lz’
/usr/libexec/grepconf.sh: line 5: grep: command not found
bash: grep: command not found…
bash: grep: command not found…
bash: uname: command not found…

MADHUKAR REDDY  REPLY TO MADHUKAR


January 9, 2018 at 6:08 am
Found the problem. Last instruction to update /etc/environment messing up
login.

Removed the contents of /etc/environment and it works fine.

For generic java 8 I would suggest the following

cd /opt
ln -s /opt/jdk1.8.0_151 jdk1.8
export JAVA_HOME=/opt/jdk1.8
export JRE_HOME=/opt/jdk1.8/jre
export PATH=$PATH:/opt/jdk1.8/bin:/opt/jdk1.8/jre/bin

NOOR  REPLY TO NOOR


February 7, 2018 at 8:10 am
I have same issue but unfortunately i cannot edit
/etc/environment file now, due to change in this file i am unable
to run any command from my user even i cannot run sudo,
sudo su or ls chown etc..
I am working on AWS Linux instance.
please help i can access files via ssh and winscp but with no
permission to edit.

GIRI  REPLY TO GIRI


January 4, 2018 at 12:23 pm
After following the instructions, my java version is still at 1.7. It has not changed to 1.8. Any reasons?

GED  REPLY TO GED


December 18, 2017 at 9:01 pm
crap, it did not work

RAHUL K.  REPLY TO RAHUL


December 19, 2017 at 4:47 am
Hi Ged. What issue are you facing?

RESHMA  REPLY TO RESHMA


November 27, 2017 at 6:36 pm
This is really saved my time. Thanks!

SHAUN  REPLY TO SHAUN


November 9, 2017 at 11:37 pm
Please update step 1. to tar xzf jdk-8u151-linux-x64.tar.gz. It still says tar xzf jdk-8u144-linux-x64.tar.gz

RAHUL K.  REPLY TO RAHUL


November 10, 2017 at 3:19 am
Thanks, Shaun to point out… The tutorial has been updated.

DANIEL  REPLY TO DANIEL


October 26, 2017 at 5:05 pm
Hi!

Apparently it’s going to work yes but i am having a problem with this command:

wget –no-cookies –no-check-certificate –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;


oraclelicense=accept-securebackup-cookie” “http://download.oracle.com/otn-pub/java/jdk/8u152-
b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz” Changed it to the last arquive (152)

It’s coming with 404 not found HTTP request, can you help me, please?

DAVID  REPLY TO DAVID


October 14, 2017 at 10:09 pm
Thank you so much Tecadmin.net! I love this post, THANK YOU!

CHETAN  REPLY TO CHETAN


September 1, 2017 at 10:16 am
Thank you for the tutorial it saves a lot of time now.

BUGSDANNY  REPLY TO BUGSDANNY


August 23, 2017 at 1:43 pm
Thank you! amazing and usefull tutorial! just what i need!.

SUMAN  REPLY TO SUMAN


August 7, 2017 at 6:06 am
Its was a great article for java config also had clear approach to solve the install conflicts for Jenkins
installation. Thanks a lot I look forward for your future articles.

BOBOTO  REPLY TO BOBOTO


August 1, 2017 at 10:03 pm
Thank you very much for this rewarding article! It was worth the try

JAYDEEP  REPLY TO JAYDEEP


July 18, 2017 at 3:00 pm
Hi,

I am not sure what I did wrong while installing java 1.8


I have followed the same steps as mentioned but when checking for JAVA version, it says 1.7.0.67 rather than
1.8.

[root@quickstart jdk1.8.0_131]# java -version


java version “1.7.0_67”
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

DEEPAK A  REPLY TO DEEPAK


December 4, 2017 at 11:48 am
Hi Jaydeep,
Could you please let me know if you could resolve this? I am stuck at this point and don’t
know how to proceed. I believe this is the reason I am not able to proceed with my SparkR
set up too and getting the below error:
————————————————–
> sc = sparkR.session(master=’local’)
Spark package found in SPARK_HOME: /home/cloudera/.cache/spark/spark-2.2.0-bin-
hadoop2.7
Launching java with spark-submit command /home/cloudera/.cache/spark/spark-2.2.0-
bin-hadoop2.7/bin/spark-submit “–conf” “spark.debug.maxToStringFields=100”
/tmp/RtmpvEvWZD/backend_port2cd67996e589
Error: Cannot load main class from JAR file:/tmp/RtmpvEvWZD/backend_port2cd67996e589
Run with –help for usage help or –verbose for debug output
Error in sparkR.sparkContext(master, appName, sparkHome, sparkConfigMap, :
JVM is not ready after 10 seconds

ROBERTO MARQUEZ  REPLY TO ROBERTO


June 28, 2017 at 3:06 pm
Thanks, I needed a way to upgrade Java from the server (command line).

MARC RAYGOZA  REPLY TO MARC


June 16, 2017 at 9:50 pm
Great article. Worked perfectly

EDUARDO FELIPE  REPLY TO EDUARDO


June 9, 2017 at 1:33 pm
Thank you, these were very especific and easy to follow instructions.

RYANTO  REPLY TO RYANTO


May 23, 2017 at 3:30 am
Hello could you explain more specific on what we’re doing on
“Also put all above environment variables in /etc/environment file for auto loading on system boot.” on the last
step. /

R.MUTHUKUMAR  REPLY TO R.MUTHUKUMAR


April 26, 2017 at 12:48 pm
Hi Team,

After exporting the path, ls command and most of the command is not working. Could you please help me on
this. I am so tired.

VERGI  REPLY TO VERGI


November 9, 2017 at 11:04 am
Did you solve your problem on this?

RAHUL K.  REPLY TO RAHUL


November 9, 2017 at 11:40 am
Hi Vergi,

Make sure you have included $PATH: in command like

export PATH=$PATH:

AYOUB  REPLY TO AYOUB


April 21, 2017 at 5:44 pm
I don’t understand the Setup “Install Java with Alternatives”???.?

YO!  REPLY TO YO!


April 19, 2017 at 11:54 am
Thanks man!

PAOLO  REPLY TO PAOLO


April 8, 2017 at 9:11 am
Thank you very much!

DAVID B.  REPLY TO DAVID


February 6, 2017 at 8:51 am
Used this to install it on 32 bit CEntos 6.5 successfully, great work!

MO CHI  REPLY TO MO
January 25, 2017 at 3:55 am
Thank you so much.

FHER  REPLY TO FHER


September 13, 2016 at 7:43 pm
Hi. From I run this commands:
echo “export JAVA_HOME=/opt/jdk1.8.0_51” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_51/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_51/bin:/opt/jdk1.8.0_51/jre/bin” >> /etc/profile.d/jre.sh

I am getting this when I open the terminal

bash: $’\342\200\234export’:order not found


bash: $’\342\200\234export’: order not found
bash: $’\342\200\234export’: order not found
[evconsul8@localhost ~]$

How this could affects?


Thanks a lot

RUBENS PINTO  REPLY TO RUBENS


November 17, 2016 at 1:22 am
See if you have a JRE.SH on /etc/profile.d

I had this one and was point to a old java version. Just deleted and is working fine.

MAX PAVLOV  REPLY TO MAX


November 24, 2016 at 2:05 pm
1. Remove your jre.sh via rm /etc/profile.d/jre.sh
2. Use these commands to correctly export variables:

echo ‘export JAVA_HOME=”/opt/jdk1.8.0_111″‘ >> /etc/profile.d/jre.sh


echo ‘export JRE_HOME=”/opt/jdk1.8.0_111″‘ >> /etc/profile.d/jre.sh
echo ‘export PATH=”$PATH:/opt/jdk1.8.0_111/bin:/opt/jdk1.8.0_111/jre/bin”’ >> /etc/profile.d/jre.sh

Reboot the machine and you’ll be fine.

FHERPIE  REPLY TO FHERPIE


September 13, 2016 at 7:40 pm
Hi. From I run this commands:
echo “export JAVA_HOME=/opt/jdk1.8.0_51” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_51/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_51/bin:/opt/jdk1.8.0_51/jre/bin” >> /etc/profile.d/jre.sh

I am getting this when I open the terminal

bash: $’\342\200\234export’:order not found


bash: $’\342\200\234export’: order not found
bash: $’\342\200\234export’: order not found
[evconsul8@localhost ~]$

How this could affects?


Thanks a lot

AMIR BAHMANYARI  REPLY TO AMIR


August 11, 2016 at 11:27 pm
Works perfectly as is. Put your env. vars in $HOME/.bashrc (if bash is the preferred shell). And you are all set.

JUAN CARLOS PAZ H  REPLY TO JUAN


July 21, 2016 at 3:31 am
Thanks , Seguí estos pasos en un sistema operativo oracle Linux y todo fue correcto muchas gracias me
ahorro mucho tiempo

HAYAM  REPLY TO HAYAM


July 6, 2016 at 2:39 pm
Hi, this is an amazing post, and I benefited a lot ! But I met a problem. After installing, i checked the version and
it was successful. However, I wanted to use the java 1.8 on system boot, and as you suggested I put the last
three commands in the “/etc/environment” file. However, after I did that, my machine is not starting (my
machine is a CentOS machine created with Cloudera training vm with help of virtualbox), and giving the
following error:

Starting jexec servicesDevice, “eth0” does not exist

Do you know what is wrong ? Can you please reply ? Thanks !

MATT  REPLY TO MATT


July 6, 2016 at 7:26 am
Could any one advise on how to sort out the envionment paths properly on Centos 7? Putting them as written
in the article in /etc/environment messes up the path meaning normal commands are missing from /bin/.
ANDRE  REPLY TO ANDRE
August 14, 2016 at 6:12 pm
Yes I also have this issue.

ANNA  REPLY TO ANNA


June 29, 2016 at 3:34 pm
Thank you. This article was really helpful.

One difference: setting the variables in /etc/environment file almost disabled the bash shell on my CentOS 7.
So I defined them in /etc/profile.d/custom.sh, it works.

It was the line with “$PATH” that had spoiled /etc/environment.


I used a command “/bin/sudo mc” to edit /etc/environment again and fix the problem.

JEREMY  REPLY TO JEREMY


June 27, 2016 at 2:57 pm
Thanks for the awesome instructions! I ran into one issue that someone else may have already mentioned,
but I did not see it. On ubuntu Alternatives has been replaced with update-alternatives. hope that saves
someone a minute or two.

DIOGO  REPLY TO DIOGO


June 20, 2016 at 1:44 pm
Thanks

PKPDEVELOPER  REPLY TO PKPDEVELOPER


June 19, 2016 at 7:58 am
Thanks Great Tutorial.Perfect

ASHOK  REPLY TO ASHOK


June 13, 2016 at 12:22 pm
This is a very good article. Concise and proper steps to setup java on any Linux box. Make a shell script with all
the above commands and run it every-time you need to setup java

KEVIN EMERY  REPLY TO KEVIN


March 4, 2016 at 5:40 am
This was rather useful, thank you

J  REPLY TO J
February 23, 2016 at 12:19 am
I removed the step of setting environment file which was empty on my machine, because adding those lines
to environment file caused serious problem (path lost).

SRIRAM  REPLY TO SRIRAM


January 19, 2016 at 7:38 am
Helped me in setting up on linode VPS when all other tutorials failes. Simple, hats off rahul

DCF  REPLY TO DCF


January 1, 2016 at 8:04 am
Excellent nicely explained the steps. thanks.

ADEMIAN  REPLY TO ADEMIAN


December 21, 2015 at 10:17 pm
Now, you have to change: download.oracle.com by edelivery.oracle.com

RAHUL  REPLY TO RAHUL


December 23, 2015 at 6:58 am
Hi Ademian,

Yes edelivery.oracle.com is also working but it still redirecting (302) to download.oracle.com.

ASHUTOSH  REPLY TO ASHUTOSH


November 4, 2015 at 1:57 pm
I tried on ubuntu 14 and it worked.
only deviation”
I wrote
export JAVA_HOME=/opt/jdk1.8.0_66
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
into ~/.profile

CHRIS  REPLY TO CHRIS


August 26, 2015 at 4:52 pm
Install is the easy part, but can anyone note the reason why you can no longer perform a “yum update jdk”
with version 1.8. I have noticed that once the package is installed, the package name format is different than
in versions 1.7 and 1.6.

Where 1.7 was formatted like so: jdk-1.7.0_80

Version 1.8 is now formatted like this: jdk1.8.0_60

This does not allow for a yum update in CentOS or Red Hat.

Thanks for any leads on this. It’s a real pain to manually update. Though I see a benefit in that you would not
“yank out” the current version out from under your running java applications. It does appear to make the
upgrade safer, but manual too.

Thanks,

MARK SMITH  REPLY TO MARK


August 21, 2015 at 8:31 am
For me, putting the “export PATH” stuff in /etc/environment causes all users to get thrown out when logging
into the GUI.
Instead, do this:
echo “export JAVA_HOME=/opt/jdk1.8.0_51” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_51/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_51/bin:/opt/jdk1.8.0_51/jre/bin” >> /etc/profile.d/jre.sh

ANKUR  REPLY TO ANKUR


September 2, 2015 at 1:58 pm
Hi Mark,

I too put the “export PATH” stuff in /etc/environment and tried to restart my machine.
Since then i am not able to login back into my Ubuntu machine. ;-(

Could you please tell how i can get the login thing working again in my system ?

So that i can apply the changes suggested in your post.

PAUL OFFORD  REPLY TO PAUL


October 17, 2015 at 2:24 pm
Hi,

I had this problem too with Centos 7. The reason is that if you put the entries
in /etc/environment it messes up the PATH environment setting which
includes removing reference to /bin.

To recover do the following:

1. Ctl-Alt-F2 to switch to a command line console


2. Login with your account details – you’ll get errors as the shell script runs
but don’t worry for the moment
3. Enter the command PATH=$PATH:/bin
4. Enter the command startx
5. Once the desktop appears open a terminal session
6. Enter the command su –
5. Enter your root password at the prompt
6. Again, enter PATH=$PATH:/bin
7. Enter the command gedit /etc/environment
8. Delete all lines in the file and save
9. Restart Centos

Best regards…Paul

SACHIN PHADTARE  REPLY TO SACHIN


August 5, 2017 at 9:34 am
Thank a lot Paul

DAWOOD  REPLY TO DAWOOD


August 7, 2017 at 2:11 am
Hi, i messed up my centos 6 machine. i have the same problem.
but i try to do what you have explained here, the instruction # 4
does not work. it says -bash: comand not found.

am really having a terrible time

FHERPIE  REPLY TO FHERPIE


September 13, 2016 at 6:08 pm
Hi everyone I would to know how resolve this:

bash: $’\342\200\234export’: order not found


bash: $’\342\200\234export’: order not found
bash: $’\342\200\234export’: order not found
[evconsul8@localhost ~]$

This happens from that I “installed java or detroyed with java my pc” I don’t know why:
I have done this:
echo “export JAVA_HOME=/opt/jdk1.8.0_101” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_101/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin” >> /etc/profile.d/jre.sh
according to Mark Smith user. All run fine. after Reboot I get that message in my terminal.
I am afraid. Because I don’t know if this affects only to java or all my apps in mi machine
Centos7

PETER  REPLY TO PETER


August 5, 2015 at 11:42 am
I cannot install to Centos 6.X.

I got the following error message:


# java -version
-bash: /usr/bin/java: cannot execute binary file

It is file permission problem or something else?

RAHUL  REPLY TO RAHUL


August 5, 2015 at 1:11 pm
Hi Peter,

Did you executed alternatives commands properly ?

XAVO  REPLY TO XAVO


July 23, 2016 at 6:17 pm
I cannot install to Centos 6.X. even I executed alternatives cmd properly

I got the following error message:


# java -version
-bash: /usr/bin/java: cannot execute binary file

ANKIT  REPLY TO ANKIT


July 15, 2015 at 6:48 am
nice, not sure about export part but rest is helpfull

KAMAL  REPLY TO KAMAL


June 23, 2015 at 6:40 am
Thanks a lot

BMIL  REPLY TO BMIL


May 29, 2015 at 9:45 pm
export PATH=$PATH:/opt/jdk1.8.0_45/bin:/opt/jdk1.8.0_45/jre/bin
Also put all above environment variables in /etc/environment file for auto loading on system boot.

export is not working, when you put it in /etc/environment file

export is shell command and /etc/environment process only static variables


variable=value

REYES  REPLY TO REYES


May 7, 2015 at 5:34 pm
I followed yout guifr but I didn’t manage to install Java on my server so I asked my hosting provider
(RoseHosting)to install Java for me. Thank you.

FELIX  REPLY TO FELIX


April 25, 2015 at 1:28 am
I tried to install on a RHEL5.10 server, but I got error when I checked the java version
java –version
Unrecognized option: –version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Please help!

RAHUL  REPLY TO RAHUL


April 25, 2015 at 3:04 am
HI Felix,
Make sure you are using single hyphen ( – ) with option -version.

ANKUJ  REPLY TO ANKUJ


April 23, 2015 at 2:08 pm
Work …centos 6.6
can any one tell me what exactly “alternatives” command doing here.

TONY  REPLY TO TONY


April 16, 2015 at 1:56 pm
Followed the instructions and it worked like a charm. Thanks much Rahul.

TAPAS  REPLY TO TAPAS


April 9, 2015 at 4:10 am
Hi Admin,

I have followed your steps but getting following error when running command ‘java -version’

-bash: /usr/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

RAHUL  REPLY TO RAHUL


April 9, 2015 at 4:13 am
Hey Tapas,

You have downloaded wrong java archive as your system architecture. Check your system
architecture using command below and download correct java archive.

uname -m

OSCAR  REPLY TO OSCAR


May 10, 2016 at 10:04 pm
a little late, but for anyone having this error maku sure you used the sudo command, so:
sudo wget –no-cookies –no-check-certificate –header “Cookie:
gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-
cookie” “http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz”

SMITH  REPLY TO SMITH


February 3, 2015 at 2:00 pm
Working nice…. thanks for easy steps…..

JONATHAN WILLIS  REPLY TO JONATHAN


January 21, 2015 at 11:15 pm
Following these instructions on CentOS 6 I get this error:

/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

RAHUL  REPLY TO RAHUL


April 9, 2015 at 4:16 am
Hi Jonathan,

You have downloaded wrong java archive as your system architecture. Check your system
architecture using command below and download correct java archive.

uname -m

JONATHAN WILLIS  REPLY TO JONATHAN


January 21, 2015 at 11:14 pm
Following these instructions on CentOS 6 I get this error:

http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/

JAY  REPLY TO JAY


January 7, 2015 at 1:31 pm
Hello sir, Im trying to install the latest java on my VPS to run a simple .jar file and the 1st step “tar xzf jdk-8u25-
linux-x64.tar.gz” returns

# tar xzf jdk-8u25-linux-x64.tar.gz


tar (child): jdk-8u25-linux-x64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Running “uname -a” returns , which I presume is 64bit, Im using Centos 6. #1 SMP Mon Aug 11 18:47:39 MSK 2014
x86_64 x86_64 x86_64 GNU/Linux. I tried installing via both SSH and terminal of the VPS itself. Both returned the
same result, what have I done wrong? Any help would be greatly appreciated.

KENT  REPLY TO KENT


December 27, 2014 at 6:05 pm
Thank you for this clear, easy-to-follow guide! With it I quickly installed Java 8 update 25.

RAHUL  REPLY TO RAHUL


April 9, 2015 at 4:18 am
Thanks Kent

DAVID+  REPLY TO DAVID+


December 22, 2014 at 10:02 pm
Yo no pude usar el mismo comando y use este “update-alternatives” y solo así pude lograrlo.

CYNDY LOOPER  REPLY TO CYNDY


December 9, 2014 at 11:12 am
Thanks alot i used it to install it on 32 bit CEntos 6.5 successfully.
WHen i tried to set up the environment variables . I got no report whatsoever after running your code. Hope i
got it correctly?

ARDHAN  REPLY TO ARDHAN


November 16, 2014 at 9:24 am
This work… thanks a lot

ALEJANDRO  REPLY TO ALEJANDRO


November 1, 2014 at 1:56 pm
This is a great concise article, working fine to centOs 6.5, thanks a lot.

CHRIS  REPLY TO CHRIS


October 28, 2014 at 9:57 am
This is a great concise article. Thank you.

FELIPE1982  REPLY TO FELIPE1982


October 28, 2014 at 6:40 am
you can append `-O jdk-8u25-linux-x64.tar.gz` to your wget line so that it renames it appropriately.

KENT  REPLY TO KENT


October 24, 2014 at 10:19 pm
This helped me with RedHat Linux 6. Thank you!

YING  REPLY TO YING


October 15, 2014 at 2:23 am
Thanks for the instructions first. I followed all the steps on CentOS. However, I got No such file or directory after
typing “java -version”. Any idea what might have caused it?

BRAD  REPLY TO BRAD


July 16, 2015 at 4:35 am
Ying, I had the same issue. I followed the steps exactly but when I tried to test that it was
working I kept getting “No such file or directory”. I tried another version of java with the same
results. Finally I traced it to (I think) to the alternative command. It seems it could not
creating the symbolic link correctly between “/etc/alternatives” and
“/opt/jdk1.8.0_45/bin/java”.
I deleted the existing link “”/etc/alternatives/java” and then recreated it:

ln -s /opt/jdk1.8.0_45/bin/java java

and now the command “java -version” displays:


java version “1.8.0_45”
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) Server VM (build 25.45-b02, mixed mode)

MAZHAR  REPLY TO MAZHAR


September 22, 2014 at 12:43 pm
Thanks a lot, very useful article.
ROB  REPLY TO ROB
September 14, 2014 at 10:33 am
Great article thanks

MAURICIO  REPLY TO MAURICIO


August 29, 2014 at 4:31 pm
Working fine to centOs 6.5, thanks a lot.

MUSTA  REPLY TO MUSTA


August 28, 2014 at 1:05 am
This work for Fedora 20?

RAVIKIRAN PATIL  REPLY TO RAVIKIRAN


August 20, 2014 at 3:25 pm
Thank you so much Rahul Kumar……. This article is the best article that I found.

LEO  REPLY TO LEO


April 30, 2014 at 4:18 pm
Thank you so much.

Maybe useful for other readers:


– On a vanilla fedora (or at least on my system), ‘alternatives’ doesn’t seem to be in the path, so the full path
has to be specified:
sudo /usr/sbin/alternatives –install /usr/bin/java java /opt/jdk1.8.0_05/bin/java 2
sudo /usr/sbin/alternatives –config java

– In case folks are not familar, the export commands can go into ~/.bash_profile , but careful not to overwrite
your existing “PATH”, instead append to it. This is an example of my ~/.bash_profile
# .bash_profile

# Get the aliases and functions


if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/Dropbox/Apps/Bash_path_linux/:/opt/jdk1.8.0_05/bin:/opt/jdk1.8.0_05/jre/bin

export JAVA_HOME=/opt/jdk1.8.0_05
export JRE_HOME=/opt/jdk1.8.0_05/jre
export PATH

Hope it helps.

JAY  REPLY TO JAY


January 7, 2015 at 1:30 pm
Hello sir, Im trying to install the latest java on my VPS to run a simple .jar file and the 1st step
“tar xzf jdk-8u25-linux-x64.tar.gz” returns

# tar xzf jdk-8u25-linux-x64.tar.gz


tar (child): jdk-8u25-linux-x64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Running “uname -a” returns , which I presume is 64bit, Im using Centos 6. #1 SMP Mon Aug 11
18:47:39 MSK 2014 x86_64 x86_64 x86_64 GNU/Linux. I tried installing via both SSH and
terminal of the VPS itself. Both returned the same result, what have I done wrong? Any help
would be greatly appreciated.

RAHUL  REPLY TO RAHUL


April 9, 2015 at 4:18 am
Hi Jay,

It looks jdk-8u25-linux-x64.tar.gz is not available at current directory. Make


sure the file exists there with correct name.

LEAVE A REPLY

COMMENTS *

NAME * EMAIL * WEBSITE


I'm not a robot
reCAPTCHA
Privacy - Terms

SUBMIT


NOTIFY ME OF FOLLOW-UP COMMENTS BY EMAIL.

All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services

You might also like