OOPS Programming in Java

manually updating java in ubuntu

Below is outlined the process of updating to the latest JDK in ubuntu and updating the alternatives link manually to point the the latest java:

Step 1: Download:

cd /usr/lib/jvm/
tar -xzf ~/downloads/jdk-7u15-linux-x64.tar.gz

Step 2: If java-7-sun already exists, the below is all that is needed if not skip to step 3 if this is the first time it is setup:

unlink java-7-sun
ln -s jdk1.7.0_15 java-7-sun

Step 3: If java-7-sun link does not already exists:

ln -s jdk1.7.0_15 java-7-sun
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-7-sun/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-7-sun/bin/javac" 1
update-alternatives --install "/usr/lib/mozilla/plugins/" "" "/usr/lib/jvm/java-7-sun/jre/lib/amd64/" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-7-sun/bin/javaws" 1

Step 4: Choose the java just installed as default:

update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javaws
update-alternatives --config

jps and jstat for tomcat on jdk-1.6.0_24

Recently upgrading to java version "1.6.0_24", jps and jstat seemed to be broken to get monitoring information from running tomcat process.

By default is /tmp, however tomcat usually uses it's own temp directory. That is where jps/jstat looks for hsperfdata_* dirs. If is not set, it would look in /tmp. If jps can't find the hsperfdata directory, it won't report anything.

jps/jstat however allows to specify in case you're using a JVM that places those directories in a different location.

So to get it to work:

$JAVA_HOME/bin/jps -l
$JAVA_HOME/bin/jstat -gc $PID

Importing existing SSL key and certificate for tomcat

  1. Convert key and cert to a single pkcs12 format.

    openssl pkcs12 -export -inkey <pathto>/key.txt -in <pathto>/cert.txt -out cert.pkcs12

  2. Remove existing tomcat aliased PrivateKeyEntry from cacerts.

    keytool -delete -alias tomcat -keystore <pathto>/cacerts

  3. Use java-1.6 keytools to import PKCS12 keystoretype into existing cacerts keystore file.

    keytool -importkeystore -destkeystore cacerts -srckeystore cert.pkcs12 -srcstoretype PKCS12

  4. Note the alias of the newly imported PrivateKeyEntry, which would normally be 1.

    keytool -list -keystore <pathto>/cacerts | grep PrivateKeyEntry

  5. Change the alias to tomcat.

    keytool -changealias -alias 1 -destalias tomcat -keystore <pathto>/cacerts

Lomboz Eclipse on Linux -- Fedora Core 5

Lomboz is an open source and free J2EE development environment built on the Eclipse open source platform and the Web Tools Platform (WTP) projects.

  1. Download and install the latest java sdk.
    # cd /usr/local
    # sh /path/to/jdk-1_5_0_07-linux-i586.bin
    # ln -s /usr/local/jdk-1_5_0_07 /usr/local/java
    # ln -s /usr/local/java/bin/java /usr/bin/java
    # ln -s /usr/local/java/bin/javac /usr/bin/javac
  2. Download and install the Eclipse SDK:
    $ wget
    # tar -C /opt -xvzf eclipse-SDK-3.1.2-linux-gtk.tar.gz
    # chown -R root:root /opt/eclipse
  3. Download and install Lomboz and prerequisites all in one package:
    $ wget
    # cd /opt
    # unzip /path/to/

    Note: Say "yes" to any prompt to replace existing file while unzipping.

  4. Start lomboz eclipse:
    $ /opt/eclipse/eclipse

Learning Java using Web Resources...

Below are some of the excellent web resources I have utilized to get me started on Java. Hope this helps others too.

  1. MITs Open Courseware: 1.00 Introduction to Computers and Engineering Problem Solving, Fall 2002
  2. Sofia Project: Introduction to Java Programming
  3. Bruce Eckels Free eBook from Thinking in Java, 3rd Edition

OpenSource Tomcat Book

Tomcat is the reference implementation of the Java Server Pages(JSP) and Java Servlet specifications. This means it is the most standards compliant Java server available.

Despite Tomcat's popularity, it suffers from a common shortcoming among open source projects: lack of complete documentation. There is documentation distributed with Tomcat mirrored at However, there is also an open source effort to write a Tomcat book at

Java Search Applet - HouseSpider !!

HouseSpider is an Java applet that adds indexing and search capability to your web site. It can search by two methods, by spidering through your site or by searching a cached index file. Spider-searching is slow, but very easy to set up and requires no maintenance. Cache-searching requires only a little more attention to set-up and is very fast, sometimes even faster than server-hosted cgi programs. HouseSpider also supports compression (in zip-format) of the index file. HouseSpider has 100% support for i18n (internationalization). It is already translated to several languages. And best of all - it is free!

Object Oriented Concepts

Object Oriented Concepts: The basic building blocks.

Syndicate content