Thursday, April 17, 2008

A Comparison of Oracle's DATE and TIMESTAMP Datatypes

Nice article on oracle DATE and TIMESTAMP's. Good place to go for quick reference.

Just go either here or here to read in detail.

Read more about "A Comparison of Oracle's DATE and TIMESTAMP Datatypes"!

Friday, April 04, 2008

Maven: a lot better then Ant

Maven is a software tool for Java project management and build automation similar in functionality to the Apache Ant. Now a days a lot of open source java project are using Maven.
Some of the main features are:-

  • Making the build process easy and it is network-ready
  • A way to share JARs across several projects
  • Providing guidelines for best practices development i.e. to write unit test
  • Creates common configuration for eclipse for users of same project.
  • more...
To get started go here http://maven.apache.org/guides/getting-started/index.html
also checkout http://en.wikipedia.org/wiki/Apache_Maven


A sample web project would look like
/project-name
/project-name/src/main/java
/project-name/src/main/resources
/project-name/src/test/java
/project-name/src/test/resources
/project-name/pom.xml
/project-name/src/main/webapp/project-name/src/main/webapp/WEB-INF

Some of the commands i use

mvn eclipse:eclipse
mvn clean
mvn install
more ...


Read more about "Maven: a lot better then Ant"!

Continuous integration

Continuous integration describes a set of software
engineering practices that speed up the delivery of software by decreasing ntegration times -Wikipedia


This is a cool concept to use which helps faster development and minimize bugs. Some of the key features are:-

  • Maintain a code repository
  • Automate the build
  • Make your build self-testing
  • Everyone commits every day
  • Keep the build fast
  • Test in a clone of the production environment
  • Make it easy to get the latest deliverables
  • Everyone can see the results of the latest build
  • Automate Deployment

For more details checkout http://en.wikipedia.org/wiki/Continuous_integration

For java developers i would recommend Hudson since its feature rich and Free!



Read more about "Continuous integration"!

Eclipse and ANT build problem with jdk1.3

You can't do an ANT build inside eclipse if your chosen jdk is 1.3. Here is a the error message you get...


BUILD FAILED
java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at org.apache.tools.ant.ProjectHelper.getProjectHelper(ProjectHelper.java:228)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:189)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:400)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)



nice little trick to fix that...

Inside Eclipse Go to Window->Preferences...->Ant->Runtime

In the classpath tab, add a new entry to the Ant Home Entries to the xerces jar file inside your eclipse/pluggins folder. In my case the file was org.apache.xerces_2.8.0.v200705301630.jar.

Now go ahead an run your build again successfully :)

update: When I updated my eclipse to 3.4, this again stopped working for me. The above fix did not work.I then saw a mailing list where the user executed the ant script by right clicking the ant script and choosing Run->Ant build..

Now change the JRE it runs in. It should be set to the option which says "Run in the same JRE as the workspace"

The mailing list thread is here

Read more about "Eclipse and ANT build problem with jdk1.3"!

How to use Read more!

Write your header message...

<span class="fullpost">Keep other stuff within your span tags</span>

I did this from here!

Only thing left to do is to enable or disable the "Read more!" which shows up at the bottom of each post!
Read more about "How to use Read more!"!

Replace ROOT context in tomcat without deleting or replacing the ROOT directory

This is a neat trick. At least it works in tomcat-4.1.24.


The first part to this trick is to know you can deploy a war file to the webapps in tomcat without adding the context in the server.xml of your tomcat installation. Suppose the name of your war file is HelloWorld.war, create an xml file called HelloWorld.xml and add the context snippet you would have added to the server.xml file to HelloWorld.xml. Now deploy both HelloWorld.war and HelloWorld.xml to the webapps folder. Voila! Your web application should now work.

The second part is to make your webapplication be the ROOT context. The ROOT context by default is the Tomcat welcome page. One way of doing this would be to just delete everything under ROOT and deploy your application in there. Well there is another way... In your Context file, just leave the path empty. Here is an example of the contents of the context file for HelloWorld.war without any resources:

<context path="" docbase="HelloWorld.war" debug="0" reloadable="true" crosscontext="true" />

That should do it.. Just bring up Tomcat and enter your url in your favourite browser.


Read more about "Replace ROOT context in tomcat without deleting or replacing the ROOT directory"!

Redirect stdout and stderr to same file

I keep forgetting the correct syntax....

% script 2>& logfile
Read more about "Redirect stdout and stderr to same file"!