0

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.
Eric Carvalho
  • 54,385

1 Answers1

1

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.

Adrian
  • 5,216