Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I switched to linux (Ubuntu 12.04) this morning and find it great but messed up while installing java. :-(.

I have installed jdk6.0_6 successfully but when I run java command in terminal, I get this

 ravi@ravi-LIFEBOOK-AH531:~$ java
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
 * gcj-4.5-jre-headless
 * openjdk-7-jre-headless
Try: sudo apt-get install <selected package>

Could someone help me with this?

Below are the steps that I followed to install:

  1. copied file named jdk-6u6-linux-x64.bin to my documents
  2. from terminal executed chmod a+x jdk-6u6-linux-x64.bin
  3. and then executed sudo ./jdk-6u6-linux-x64.bin
  4. In terminal I accepted the license agreement and done.
share|improve this question
    
Please tell us exactly how did you installed java. This can help you: How do I install Oracle JDK 6?. –  Eric Carvalho Dec 15 '12 at 15:08
    
askubuntu.com/q/67909/65926 this link worked for me. Thank you –  Ravi.Kumar Dec 15 '12 at 16:11

1 Answer 1

up vote 1 down vote accepted

The location you installed Java to is probably not on your PATH variable. This is the list of directories the OS looks for executables in.

You can see this environment variable with

echo $PATH

You can edit the path your user gets by changing your ~/.profile script, or the PATH the whole system gets by adding a script to /etc/profile.d ; you'll need to add the folder the java executable is in.

An alternative is to make a symlink to the java executable from a folder that is already on your path.

The third alternative is to install one of the available Java packages from the Ubuntu repositories instead of downloading packages from Oracle. For most purposes, OpenJDK works fine, OpenJDK 7 being the official standard JDK for the Java compliance testing now. The Ubuntu packages of Java work correctly without additional setup for most cases.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.