Install Java on Ubuntu/Linux

5

1

I am a windows user, and wonder how do I go about installing java on Ubuntu (VirtualBox)

I have tried

sudo apt-get install sun-java6-bin

got

couldnt find package

sudo apt-get install sun-java6-jre

got

sun-java6-jre has no installation candidate

I also tried the .bin file:

sudo chmod 755 <filename>.bin
./<filename>.bin

Seems like it has done its things without errors, but

java -version

gives

the program 'java' can be found in the following package ...

Jiew Meng

Posted 2010-07-23T15:33:52.833

Reputation: 1 263

Total duplicate. – Apache – 2010-07-23T16:15:51.193

possible duplicate of Java and Ubuntu

– Apache – 2010-07-23T16:16:53.717

Answers

6

Sun Java has been moved to the Partner repository in Ubuntu 10.04 (Lucid Lynx).

Add the repository by doing this:

add-apt-repository "deb http://archive.canonical.com/ lucid partner"

Then you can do:

sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

Paused until further notice.

Posted 2010-07-23T15:33:52.833

Reputation: 86 075

0

The steps to install Java 8 on Ubuntu:

  1. At first, download the package file from the official website.

    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. The download package is different for 64 bit and 32-bit versions.

  2. You will need some superuser privileges to install JDK. So use the following command-

    sudo su
    
  3. The /opt directory is actually reserved for all the software and add-on packages. This software is not part of the default installation. The command for creating directory for JDK installation is

    mkdir /opt/jdk
    
  4. Then extract java into the /opt/jdk directory:

    tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
    
  5. Then use the following command. This command verifies the file extraction into the /opt/jdk directory.

    ls /opt/jdk
    
  6. By default, you can find java executable in /opt/jdk/jdk1.8.0_05/bin/java directory. To set it as the default JVM use:

    update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100
    update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100
    
  7. Then verify the java has been successfully configured. Run the following commands:

    update-alternatives --display java
    update-alternatives --display javac
    

    You can check installation by

    java -version
    
  8. You can also update Java. Hence, download an updated version of Oracle’s website and extract to the /opt/jdk directory. After that, set it as the default JVM with a higher priority number:

    update-alternatives --install /usr/bin/java java /opt/jdk/jdk.new.version/bin/java 110
    update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk.new.version/bin/javac 110
    

simran

Posted 2010-07-23T15:33:52.833

Reputation: 1

1Why is this preferable to installing from the repository? – fixer1234 – 2018-09-21T06:04:25.720