Rebirth of T-rex

Does dinosaur really extinct? What caused the dinosaur to vanish? Have you ever wonder whether the real 'you' is disappearing and slowly vanishing? Hope that through this blog, we will be able to maintain the real self.

Sun Certified Java Programmer

Posted by T-rex Lim Huat Heng

I just sat for Sun Certified Java Programmer exam yesterday and it was an interesting experience. Yeah! I passed! It was not only the exam session that I sat for, but also the whole preparation process that gave me a new insights. Thus, I would like share some of them with you here.

Firstly, I would encourage any Java programmer/developer who hasn't sit for this exam to start looking into it and register for it. It's not the cert (the paper you get upon passing the exam) that gives you the most value, but the knowledge that you acquired when preparing for the exam that bring you to another level. I have always asking myself how I can write a robust code- I can say that this certification is the first step.

The following are some of the references that I would like to share for you to understand what SCJP is, how to kick-start your preparation for the exam and how to enhance and testify your knowledge with the mock exams. Please take note that the following are some of my recommendations (just my 2 cents) and it does not guarantee as the best.

General:
http://www.sun.com/training/certification/java/index.html
http://www-106.ibm.com/developerworks/java/library/j-scjp/

Book:
Exam Cram 2- Java 2 Programmer by Bill Brogden and Marcus Green

Mock Exams/ Tests (Please ignore questions on AWT and IO since it's not covered in SCJP 1.4):
JWhiz1.4
PrepLogic Preview Edition for Exam 310-035 (in the CD of the Exam Cram 2- Java 2 Programmer book)
http://www.javaprepare.com/quests/test.html
http://www.javaprepare.com/quests/test2.html
http://www.javaprepare.com/quests/question.html
http://www.jchq.net/mockexams/exam2.htm
http://www.jchq.net/phezam/login.php

Notes/Tutorials:
www.whizlabs.com/tutorial/scjp/j-scjp-a4.pdf
http://www.jchq.net/certkey/index.htm
http://www.javaprepare.com/notes/intro.html

All the best!

First Java Program with J2SE 5.0 New Feature

Posted by T-rex Lim Huat Heng

Happy New Year to everyone! New resolutions for a new year. As I was still pin down by sickness, coughing seriously, no special celebration was undergone for this new year. I felt pretty sorry for not able to join my sister and friends back in PJ on the new year eve.

Anyway, I ended the day with a simple Java program, in fact, the first Java program with the new features introduced in J2SE5.0 (Tiger), in particularly enhanced for loop.

I wrote the program using JCreator, a light weight Java IDE. You can obtain a free JCreator LE (Build 3.50.009) at http://www.jcreator.com/download.htm.

Besides, you must have JDK 5.0 in place; I would recommend you download and install JDK 5.0 Update 1 (from http://java.sun.com/j2se/1.5.0/download.jsp) as that's the latest release. Ensure the JAVA_HOME is added in the environment variable, please refer to my previous posting- Hypersonic SQL (http://trexlim.blogspot.com/2004/12/hypersonic-sql.html) for reference.

You are required to set the compiler to the used in JCreator. Launch JCreator and select Configure > Options from the menu. Click on JDK Profiles and click on New button, then browse to JAVA_HOME. Click OK button and then Apply button.

The following is the source code I have written:
import java.util.ArrayList;

public class Test {
   public static void main(String[] args) {

      // Create a new list and add some strings to it
      ArrayList mylist = new ArrayList();
      mylist.add("a");
      mylist.add("b");
      mylist.add("c");

      // Use enhanced for loop to show the element added into the list
      for(String str : mylist) {
         System.out.println(str);
      }
   }
}

After you compile (using menu Build > Compile in JCreator) the above (provided no compilation error) and run the program (via menu Build > Execute File in JCreator), the following should be the expected output printed on the console:
a
b
c

Migrating from Tomcat 5.0.28 to Tomcat 5.5.4

Posted by T-rex Lim Huat Heng

I was working on a project last week in which the application was initially deployed in Tomcat 5.0.28 in my local PC. As I would like to evaluate how JDK 5.0 perform in my local PC, I tried my luck in migrating the application to Tomcat 5.5.4, which is intended for supporting JDK 5.0.

The migration was quite a straight forward process as I just need to change the path for JAVA_HOME (pointing to where JDK 5.0 is installed, eg. c:\j2sdk1.5.0_01) and CATALINA_HOME (where the Tomcat 5.5.4 is installed, eg. c:\jakarta-tomcat-5.5.4) in my system's environment variables; then add the context configuration file in CATALINA_HOME\conf\Catalina\localhost folder, in particularly myapp.xml.

The issue that I faced when the migration was performed was on the content of myapp.xml. I had the following the old myapp.xml:

<Context privileged="true" debug="0" path="/myapp" docBase="c:\software\IDE\eclipse-3.0.1\workspace\myapp">

<Resource name="jdbc/myappdb" type="javax.sql.DataSource" auth="Container">
<ResourceParams name="jdbc/myappdb">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@localhost:1521:dev</value>
</parameter>
<parameter>
<name>username</name>
<value>myappusrid</value>
</parameter>
<parameter>
<name>password</name>
<value>myapppwd</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
</Context>


However, after simplifying the above to the following, it was running well!
<Context privileged="true" debug="0" path="/myapp" docBase="c:\software\IDE\eclipse-3.0.1\workspace\myapp">

<Resource name="jdbc/myappdb" url="jdbc:oracle:thin:@localhost:1521:dev" username="myappusrid" password="myapppwd" type="javax.sql.DataSource" auth="Container" driverclassname="oracle.jdbc.driver.OracleDriver" maxactive="20" maxidle="10" maxwait="-1">
</Context>


Enjoy and good luck!