Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing sun-java6-jre gives error

I am installing sun-java6-jre on ubuntu 12.04, but I am getting the following error,

The following packages have unmet dependencies:
 sun-java6-jdk : Depends: sun-java6-bin (= 6-06-0ubuntu1) but it is not going to be installed
 sun-java6-jre : Depends: sun-java6-bin (>= 6.30-2~precise1) but it is not going to be installed or
                      ia32-sun-java6-bin (>= 6.30-2~precise1) but it is not going to be installed
                 Recommends: gsfonts-x11 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Please help!

like image 987
MJQ Avatar asked Jul 10 '12 15:07

MJQ


2 Answers

Sun Java is no longer available for Ubuntu in this way.

Will

sudo apt-get install openjdk-6-jdk 

be good enough for what you need?

like image 164
Thorbjørn Ravn Andersen Avatar answered Oct 22 '22 03:10

Thorbjørn Ravn Andersen


You may follow this detailed procedure:

Refer:

http://www.oracle.com/technetwork/java/javase/downloads/index.html http://hendrelouw73.wordpress.com/2012/06/01/how-to-install-oracle-java-6-0-32-on-ubuntu-12-04-linux/

Download:

Download following files from http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK: jdk-6u37-linux-i586.bin (or jdk-6u37-linux-x64.bin for 64 bit system) JRE: jre-6u37-linux-i586.bin

Installation Procedure:

  1. Make sure the installation folder exists:

    $ sudo mkdir -p /usr/lib/jvm

  2. cd to folder containing jre and jdk bin files

  3. Move the downloaded files to installation folder

    $ sudo mv jdk-6u37-linux-i586.bin /usr/lib/jvm

    $ sudo mv jdk-6u37-linux-x64.bin /usr/lib/jvm (for 64 bit system)

    $ sudo mv jre-6u37-linux-i586.bin /usr/lib/jvm (only if, you are installing just JRE)

  4. $ cd /usr/lib/jvm

  5. Make the downloaded binaries executable

    $ sudo chmod u+x jdk-6u37-linux-i586.bin

    $ sudo chmod u+x jre-6u37-linux-i586.bin (only if, you are installing just JRE)

  6. Extract both compressed binary files:

    $ sudo ./jdk-6u37-linux-i586.bin

    $ sudo ./jre-6u37-linux-i586.bin (only if, you are installing just JRE)

  7. Inform Ubuntu where your Java installation is located

    $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_37/bin/javac" 1

    $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_37/jre/bin/java" 1

    $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_37/bin/javaws" 1

    $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_37/bin/java" 1 (only if, you are installing just JRE)

  8. Inform Ubuntu that this is you default Java installation:

    $ sudo update-alternatives --set javac /usr/lib/jvm/jdk1.6.0_37/bin/javac

    $ sudo update-alternatives --set java /usr/lib/jvm/jdk1.6.0_37/jre/bin/java

    $ sudo update-alternatives --set javaws /usr/lib/jvm/jdk1.6.0_37/bin/javaws

    $ sudo update-alternatives --set java /usr/lib/jvm/jre1.6.0_37/bin/java (only if, you are installing just JRE)

  9. Reload your system-wide PATH

    $ . /etc/profile

  10. Reboot you Ubuntu system Checking versions:

    $ java -version

    $ javac -version

    $ javaws -version

You should be able to see:

java version "1.6.0_37" javac 1.6.0_37

Setting JAVA_HOME:

Add following code to ~/.bashrc file:

# Setting JAVA_HOME manually 

JAVA_HOME=/usr/lib/jvm/jdk1.6.0_37

export PATH=$PATH:$JAVA_HOME

Now, open a new terminal:

$ echo $JAVA_HOME 
=> /usr/lib/jvm/jdk1.6.0_37/bin

Installation and Registration of Java Plugin for Linux:

Refer: http://www.oracle.com/technetwork/java/javase/manual-plugin-install-linux-136395.html When you install the Java platform, the Java plugin file is included as part of that install. If you want to use Java within Firefox, you need to manually create a symbolic link from the plugin file in the release to one of the locations that Firefox expects. You can create the symbolic link in your home directory, in ~/.mozilla/plugins. The plugin file for Linux is located here: /lib/i386/libnpjp2.so

To install the Java Plugin follow these steps:

  1. Exit Firefox.
  2. $ cd ~/.mozilla/plugins/
  3. Uninstall any previous installations of Java Plugin. Only one Java Plugin can be used at a time. When you want to use a different plugin, or version of a plugin, remove the symbolic links to any other versions and create a fresh symbolic link to the new one. Remove the existing symbolic links (or move them to another directory):

    $ rm libnpj*

  4. Create a symbolic link to the Java Plugin in the Firefox plugins directory.

    $ ln -s /usr/lib/jvm/jdk1.6.0_37/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

    $ ln -s /usr/lib/jvm/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/ (in case for 64 bit system)

    $ ln -s /usr/lib/jvm/jre1.6.0_37/lib/i386/libnpjp2.so ~/.mozilla/plugins/ (only if, you are installing just JRE)

  5. Start the Firefox browser . Testing installed plugin: Type about:plugins in the Location bar to confirm that the Java Plugin is loaded. You can also click the Tools menu to confirm that Java Console is there.

like image 45
Munish Avatar answered Oct 22 '22 03:10

Munish