Ubuntu Linux Install Sun Java Development Kit ( JDK ) and Java Runtime Environment ( JRE )

Leave a comment

Question :
How do I install Sun Java Development Kit (JDK) and Java Runtime Environment (JRE) under Ubuntu Linux? It appears that there are multiple JRE installed by default under Ubuntu. How do I select and use Sun JRE only? Can you explain steps required to set the environment to run java programs or apps?

Answer:
Ubuntu Linux 7.10 has following packages from Sun:
=> sun-java6-bin : Sun Java Runtime Environment (JRE) 6

=> sun-java6-demo : Sun Java Development Kit (JDK) 6 demos

=> sun-java6-jdk : Sun Java Development Kit (JDK) 6

=> sun-java6-jre : Sun Java Runtime Environment (JRE) 6

Open a shell prompt (terminal) and type the following to install JDK and JRE:

$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Setup the default Java version

Ubuntu Linux comes with update-java-alternatives utility to updates all alternatives belonging to one runtime or development kit for the Java language. To select, Sun’s JVM as provided in Ubuntu 7.10, enter:

$ sudo update-java-alternatives -s java-6-sun

You also need to edit a file called /etc/jvm. This file defines the default system JVM search order. Each JVM should list their JAVA_HOME compatible directory in this file. The default system JVM is the first one available from top to bottom. Open /etc/jvm

$ sudo vi /etc/jvm

Make sure /usr/lib/jvm/java-6-sun is added to the top of JVM list

/usr/lib/jvm/java-6-sun

At the end your file should read as follows:

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr

Save and close the file.

Setup the environment variable

You also need to setup JAVA_HOME and PATH variable. Open your $HOME/.bash_profile or /etc/profile (system wide) configuration. Open your .bash_profile file:

$ vi $HOME/.bash_profile

Append following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

Save and close the file.

Test your new JDK
Type the following command to display version:

$ java -version

Output:

java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

Try HelloWorld.java – first java program

$ vi HelloWorld.java

Append code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Save and close the file. Compile HelloWorld.java and execute program by typing following two instructions:

$ javac HelloWorld.java
$ java HelloWorld

Output:

Hello, World!

Install Chromium with Flash Player Plugin in Ubuntu

Leave a comment

Well its been a while since a wrote a howto for you guys and just stumbled across this which I am very excited about. We all know about google’s browser chrome, it is fast and sleek, and now is pretty much ready for beta, I have no problems whatsoever with Chromium any longer. I am now using it as my default browser in Ubuntu Jaunty! Here is the quickest way possible to install chromium and get it up and running with flash.

sudo gedit /etc/apt/sources.list

Add these two Lines:

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main

Between replace jaunty with intrepid if your still using that.

Now add the GPG Key:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xfbef0d696de1c72ba5a835fe5a9bf3bb4e5e17b5
sudo apt-get update ; sudo apt-get install chromium-browser

Now once installed Go to Applications->Internet->Chromium Browser and right click it, add to panel
Right click the new chromium icon and add the following where it says command:

chromium-browser --enable-plugins

Note: You’ll of course need flash installed for firefox first, to install that:

sudo apt-get install adobe-flashplugin

Now lets install flash before we launch this baby:

sudo cp /usr/lib/firefox/plugins/flashplugin-alternative.so /usr/lib/chromium-browser/plugins/flashplugin.so

Please enjoy flash with chromium with Angkor Wat History in youtube first.