Install Sun Java with the Firefox Plugin on an Ubuntu Live CD or USB



When running Ubuntu from a live cd or live usb, and trying to install java, the following errors appear:

java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory


OR

Setting up sun-java6-bin (6-06-0ubuntu1) ...
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.

Getting and Preparing the files

Adding the Multiverse and Universe Repositories

Go to 'System', 'Administration', 'Software Sources'.

On the 'Ubuntu Software' tab tick the multiverse and universe boxes.

Click 'Close'. It will ask you to reload/refresh; DO IT!

Getting and Installing Java

Online Install

Do this in a terminal for JRE (basically if you're not a java developer):

* sudo apt-get install sun-java6-jre sun-java6-plugin

Do this in a terminal for JDK (basically if you ARE a java developer):

* sudo apt-get install sun-java6-jdk sun-java6-plugin

Say yes to whatever asks. If you are on a live CD or USB (even if it is Feisty 7.04, Gutsy 7.10, or Hardy 8.04 - I tried them all) you will probably get something like this:

Setting up sun-java6-bin (6-00-2ubuntu2) ...
/usr/lib/jvm/java-6-sun-1.6.0.00/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
dpkg: error processing sun-java6-bin (--configure):
subprocess post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of sun-java6-plugin:
sun-java6-plugin depends on sun-java6-bin (= 6-00-2ubuntu2); however:
Package sun-java6-bin is not configured yet.
dpkg: error processing sun-java6-plugin (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of sun-java6-jre:
sun-java6-jre depends on sun-java6-bin (= 6-00-2ubuntu2) | ia32-sun-java6-bin (= 6-00-2ubuntu2); however:
Package sun-java6-bin is not configured yet.
Package ia32-sun-java6-bin is not installed.
dpkg: error processing sun-java6-jre (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
sun-java6-bin
sun-java6-plugin
sun-java6-jre
E: Sub-process /usr/bin/dpkg returned an error code (1)
Fixing that Error
Go into a terminal and do the following:
(Copy and paste using right-click so you don't get any of them wrong)

1.sudo su

2. LD_LIBRARY_PATH=CHANGEME dpkg --configure -a

-----The CHANGEME part should be changed to the location of libjli.so
-----Open your File System, go Ctrl+F, search for 'libjli'
-----Mine was in '/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/i386/jli'
----------so I used LD_LIBRARY_PATH=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/i386/jli dpkg --configure -a

3.ln -s / /cow

4. Run whichever of these you used before again:

sudo apt-get install sun-java6-jre sun-java6-plugin
sudo apt-get install sun-java6-jdk sun-java6-plugin

-----Say yes to anything it asks.
-----It should work perfectly this time with no errors.


Verification of Success

In a terminal type:

java -version

Something like this should appear:

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)
In firefox, where you would type a website type:
Code:

about:plugins

You should see something like this (you might have to scroll to find it):
Quote:
Java(TM) Plug-in 1.6.0_06-b02

File name: libjavaplugin_oji.so
Java(TM) Plug-in 1.6.0_06
With a huge table underneath it.

Go to this website: http://java.com/en/download/help/testvm.xml

An applet will run near the bottom if you java is working correctly.