0

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.

asked Apr 20, 2012 at 17:14

3 Answers 3

2

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...

answered Apr 20, 2012 at 17:18
Sign up to request clarification or add additional context in comments.

5 Comments

I get this error with the command you gave me, premvidya@ubuntu:~$ apt-get cache search java apt-get cache search jdk E: Invalid operation cache..How do I go to the Ubuntu software center..I new to Linux
Here is my output result,premvidya@ubuntu:~$ apt-cache search java6 premvidya@ubuntu:~$ apt-cache search java gdb - The GNU Debugger libdbus-1-3 - simple interprocess messaging system dbus - simple interprocess messaging system libgtksourceview-common - common files for the GTK+ syntax highlighting widget openoffice.org-core - full-featured office productivity suite -- arch-dependent files brltty - Access software for a blind person using a braille display libgtksourceview2.0-common - common files for the GTK+ syntax highlighting widget
sudo apt-get update ; sudo apt-get upgrade ; clear ; echo "now type apt-cache search java"
I think your package repos are very out of date if all apt-cache search java6 produced was what you posted. You might want to go to System -> preferences -> software sources and check things out.
sudo apt-get install openjdk-6-jdk openjdk-6-jre
1

@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 !!

answered Nov 17, 2013 at 6:49

Comments

0

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.

answered Apr 20, 2012 at 19:31

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.