Thursday, August 11, 2011

Enabling Java in Ubuntu and Mozilla, Jar execution

Hi folks.

Today's Aim
  1. Enable Java in Ubuntu 11.
  2. Execute Applets in Mozilla in Ubuntu, adding the Java plug-in to Mozilla Firefox in Ubuntu.
  3. Execute Jar files directly in Ubuntu for which we do not have execute access.

I have been working on Java for a long time on Windows systems. Yesterday I was giving a try on Ubuntu and really felt the pain of getting Java up in Ubuntu. So I decided to dot my learning in this article.

Task 1: Enable Java in Ubuntu 11
Ubuntu comes with an open jdk for running Java. We need to install it, or else we may get it from Sun Microsystems (Now Oracle) also. I preferred the open-jdk as it was much easier to install and get running.

Steps:
  • Open Terminal
  • Type: java -version. This will give the list of packages containg java.I got the below listing on my machine.
                      $ java -version
                       The program 'java' can be found in the following packages:
                       * gcj-4.4-jre-headless
                       * gcj-4.5-jre-headless
                       * openjdk-6-jre-headless
                        Try: sudo apt-get install
  • Select the openjdk to be installed. My machine's screen text is below:
               $ sudo apt-get install openjdk-6-jre-headless
  • This will install Java in your Ubuntu machine.

Task 2: Execute Applets in Mozilla in Ubuntu, adding the Java plug-in to Mozilla Firefox in Ubuntu.
For enabling Java in Mozilla Firefox in Ubuntu so that it can run Java Applets, follow the below steps.
  • Open Terminal
  • Install icedtea6-plugin. The screen-text from my machine is:
                      $ sudo apt-get install icedtea6-plugin
  • This will install the icedtea6-plugin on your Ubuntu Mozilla Firefox and will enable you to run Java Applets.
 
Task 3: Execute Jar files directly in Ubuntu for which we do not have execute access.
This was the most tricky of all. I had a jar file which i made through my Windows login for which i do not have execute access on Ubuntu machine. I tried chmod, chown, manually changing the permissions, etc, but all failed. The trick that finally worked was with Terminal again.

Use the following command to execute jar files in Ubuntu from Terminal.
$ java -jar filename


The screentext from my machine is:-
$ java -jar HelloWorld.jar

the above jar is a Java Applet and it executed just perfectly fine on Ubuntu. I also heard about some software called Wine for the same purpose, but did not tried it, as my job got done with the Terminal.

I hope the article will be useful to my readers. Will keep posting on more updates from my-side on this Java blog.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.