2

I was installing JDK7 on Ubuntu 12.04 by following the guide posted on web8. The commands posted in the guide were:

sudo mkdir -p  /usr/lib/jvm/ #just in case
sudo mv java-7-oracle/ /usr/lib/jvm/
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java
sudo update-java

Till here everything went well. So hopefully jdk was installed correctly, but then when I tried to check the java version with the command:

java -version

...it gave me this error:

bash: /usr/bin/java: Permission denied

Yes i know this is a permission related issue. And it can be solved using the sudo command, but can someone tell the exact command? I also checked permissions using ls -l command and the output was:

-rw------- 1 ankit ankit   5650 Jun 27  2011 java  
-rw------- 1 ankit ankit   5805 Jun 27  2011 javac

None of the tutorials and videos i saw were having this issue why is it only me?have i messed up with some default configurations? do i need to change the permission to the /usr/ directory evrytime?

I know this may sound stupid to many here, but i really want to know exactly where I am going wrong.

Eliah Kagan
  • 119,640

2 Answers2

5

Probably the execution flag is not true on this java script.
Try executing sudo chmod +x /usr/bin/java and see if the permission is back.

If that solved the issue, do the same for /usr/bin/javac.

yossile
  • 5,828
2

Following the same website, it now maintains a PPA for stable Oracle JDK7 which you can install using following ways.

First and foremost, follow the same source which suggests how to remove manually installed JDK and revert back the changes.

Then, add PPA for JDK7 as follows,

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get-update
sudo apt-get install oracle-jdk7-installer

Than, this will pull the latest version of JDK7 from Oracle and also will keep you up-to-date with JDK.

You can find out official guide from WebUpd8.org here.

WebUpd8.org is great source by the way, you can check out other PPAs it maintains here.

Kushal
  • 2,390