user1050619
user1050619

Reputation: 20856

installing java in linux issues

Im trying to install Java in install but for some reason its not working.

I tried the same way as mentioned in this website-http://www.java.com/en/download/help/linux_install.xml#enable

I see Java installed in my desktop when I try this command,

premvidya@ubuntu:~/Desktop$ ls jre1.6.0_31 jre-6u31-linux-i586(2).bin jre-6u31-linux-i586.bin

but when I try java - version, I get the following error,

premvidya@ubuntu:~/Desktop$ java -version The program 'java' can be found in the following packages: * gij-4.3 * java-gcj-compat-headless * openjdk-6-jre-headless * cacao * gij-4.2 * jamvm * kaffe Try: sudo apt-get install bash: java: command not found

Any help would be appreciated.

Upvotes: 0

Views: 1662

Answers (3)

Mayur Patil
Mayur Patil

Reputation: 972

@user1050619

Hi user1050619,
I have come across the solution which will work on any version of Ubuntu definitely keeping other java versions intact.

I have used standalone installation of Java.

For this, please download tar.gz version of Java from Oracle website.

  1. Suppose, your jdk installation tar file at location /home/don/

  2. don@ubuntu ~ $ tar zxf jdk-7u45-linux-i586.tar.gz

  3. don@ubuntu ~ $ sudo bash

    [sudo] password for don:

  4. ubuntu ~ # mv /home/don/jdk1.7.0_45/ /usr/lib/jvm/

  5. ubuntu ~ # cd /usr/lib/jvm/

  6. ubuntu jvm # update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_45/bin/java 3

  7. ubuntu jvm # update-alternatives --config java

 Selection    Path                                           Priority   Status  
------------------------------------------------------------  
* 0            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      auto mode  
  1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      manual mode  
  2            /usr/lib/jvm/jdk1.7.0_45/bin/java               3         manual mode  
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in manual mode
  1. ubuntu jvm # java -version
    java version "1.7.0_45"
    Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
    Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)

and you are done here without any hassles.

Happy programming !!

Upvotes: 1

MichaelN
MichaelN

Reputation: 1744

it should be "apt-cache search java6" or just "apt-cache search java". It'll give you a list of all the package related to java. If you want to install sun's java then you download the java-**.bin file like you did and then run "sudo /bin/sh jre-6u31-linux-i586.bin" That'll run the installer from the sun java you downloaded and begin to install. Answer the question and install the package.

Upvotes: 0

Adam Miller
Adam Miller

Reputation: 1783

Why are you trying to manually install java? There is a repository for this, and it's all managed for you. Uninstall whatever you have put on your system manually and install it via command line.

apt-get cache search java apt-get cache search jdk

or start Ubuntu Software Center -> search for java.

Once installed via apt-get, the new java commands will be available immediately in your PATH, so long as you haven't removed anything...

Upvotes: 2

Related Questions