Saturday, November 12, 2005

Setting java heap size, for java and ant

If you are using the java command prompt, you can very well set the heap size with the -Xms switch.
example:
java -Xms64m -Xmx512m
where
-Xms specifies the initial Java heap size and
-Xmx the maximum Java heap size.

If you are using Ant to run your java classes, set the heap size using the following command line:
set ANT_OPTS=-Xmx300M

Friday, November 11, 2005

Maven for automated build and reporting

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Maven Documentation

All the documentation for Maven is in the form of guides which can all be found here.

About Maven 2.0

Maven 2.0 is a rewrite of the popular Maven application to achieve a number of goals, and to provide a stable basis to take it into the future.

Wednesday, November 09, 2005

HyperJaxb, quick start guid

What is HyperJaxb?
HyperJaxb is a set of libraries developed and maintaied by the java.net community. To understand HyperJaxb you should understand both jaxb and Hibernate in some details. HyperJaxb provides a bridge between the jaxb generated objects and the Hibernate mapping. In layman's term, using HyperJaxb, you can simply drop your xsd in a folder, run a magical script and you can see both the java objects as well as relational tables created for you! Aint it promising?

What can we do with Hyperjaxb?
We can do magical things with this new api, if used properly. Especially in a services driven application(SOA), we can completely concentrate on the xsd's to design our application without worrying about the underlying data/object layer or the back end relational layer. We can simply leaverage jaxb, hyperjaxb and hibernate to do the dirty work for us. For instance, I can create a catalog.xsd template to supply catalog xml data to customer webservices and the user facing front end. This xsd will be converted by HyperJaxb into java objects that can be used in application programming as well as relational structure that will store the actuall data! Now say the customer adds a new element in the catalog.xsd; all we need to do is regenerate the jaxb objects and the backend tables! No redesigning of the object and db layer. (Obviously you will have to migrate the data and implement the new business logic if any, manually).

How does HyperJaxb works?
hyperjaxb leverages a cool feature introduced in Hibernate, called as XDoclet. Using XDoclet, you can trick the standard java compiler by adding attribute oriented code snippets right in the program comments. When you compile a xsd using HyperJaxb(instead of the standard jaxb), you end up creating jaxb like java classes with XDoclet annotations in these java files that will contain the mapping information. Now you dont have to write the mapping information on your own. HyperJaxb will generate it all for you.

How to get HyperJaxb working?
  • Download and install the latest stable release of HyperJaxb in c:\program files from here.
  • Create the following folder structure:
    • C:\dev\hyperJaxb
      • hibernate (hibernate property files will sit here)
      • myTestApp (Your sample test application)
        • schema (place your favourite scample catalog.xsd schema file here)
        • sample (sample xml file for the above schema)
  • copy the following files from C:\Program Files\hyperjaxb\tests into c:\dev\hyperjaxb
    • build.xml
    • runtest.bat
    • test.build.xml
  • Modify build.xml
    • Completely delete the following tags:
      • test.all and clean.all
    • Replace them with
      • myTestApp
    • Check the relative location for build.xml
      • It should be ../test.build.xml
    • save and exit this file
  • Modify test.buil.xml
    • Replace main.dir value to
      • C:/Program Files/hyperjaxb
    • Replace hsqldb.lib.dir location to C:/Program Files/jtds-1_1
      • In this step we are replacing the hsql driver by the jtds driver so that we can connect to sqlserver.
  • copy the following files in C:\dev\hyperJaxb\hibernate from C:\Program Files\hyperjaxb\tests\hibernate
    • hibernate.export.properties
    • hibernate.properties
  • Modify both these files:
    • Comment everything.
    • Search for the word server; and below it add the following lines:
      • hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
        hibernate.connection.username sa
        hibernate.connection.password password
        hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
        hibernate.connection.url jdbc:jtds:sqlserver://localhost:1433/hibernateTest
  • Create a blank database in sqlserver with the name hibernteTest, and make sure that sqlserver is up and running on port 1433 on localhost.
  • Go to the command prompt and execute the following command:
    • runtest myTestApp
  • If everything is set properly, you should see database tables created in the database and jaxb files created.
@reference

hibernate properties for jtdc drivers and sqlserver

hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
hibernate.connection.username sa
hibernate.connection.password password
hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
hibernate.connection.url jdbc:jtds:sqlserver://localhost:1433/hibernateTest


You need to have C:\Program Files\jtds-1_1\jtds-1.1.jar in your classpath.

Tuesday, November 08, 2005

jaxb, quick start guide

Here is a quick start from my experience:
  • Install jaxb: Remember jaxb will not come as a seperate installation. So finding a jaxb installation on java.sun is futile. Download and install the latest version of jwsdp. I have installed it here: "c:\Program Files\jwsdp-1.6". You can find jaxb in C:\Program Files\jwsdp-1.6\jaxb
  • The magical xjc compiler that does it all can be found in: C:\Program Files\jwsdp-1.6\jaxb\bin\xjc.bat
  • Always have the latest stable java build installed with you: C:\Program Files\Java\jdk1.5.0_04. Note JDK and not JRE! tools.jar is not found in jre.
  • Create a development/work folder something like c:\dev\jaxb. You will eventually have the following folder\file structure here:
    • c:\dev\jaxb
      • \lib (for supporting libs)
      • \work (for java files generate by the xjc compiler)
      • \classes (for class files generated by the javac compiler)
      • catalog.xsd (schema file to be persisted)
      • setEnv.bat
  • Copy the following files in dev\lib from the jaxb installation: jax-qname.jar, jaxb-api.jar, jaxb-impl.jar, jaxb-libs.jar, jaxb-xjc.jar, namespace.jar, relaxngDatatype.jar
  • Our generated schema classes will be kept under: dev\jaxb\classes
  • Create a setEnv.bat file. Mine looks like this:
  • @ECHO ON
    set CLASSPATH=.
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\classes
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\classes\myTest
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\jax-qname.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\jaxb-api.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\jaxb-impl.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\jaxb-libs.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\jaxb-xjc.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\namespace.jar
    set CLASSPATH=%CLASSPATH%;C:\dev\jaxb\lib\relaxngDatatype.jar
  • Copy your favourite xsd file in the c:\dev\jaxb folder.
  • On command prompt execute the setEnv.bat file.
  • (Make sure you have things like jav\bin, ant\bin etc in the system path variable)
  • Once the env is set, you are all set.
  • To generate java files in teh work folder, run the following command:
    • xjc -p myTest catalog.xsd -d work
    • You just compilled your entire schema into .java classes with package structure myTest under the work folder. Nice!
  • To generate .class files from the generated .java files, use the following command line:
    • javac -d classes work\myTest\*.java
  • YOU ARE DONE!
  • Testing persistance:
    • change your directory to work folder. You should see the myTest package created here.
    • Now create a folder named: "client".
    • Copy the JAXBConstructor.java file from this zip.
    • Compile and run this file with a sample xml as input.


Very nice articles that gets you started with jaxb:
@link
@sun

iBATIS: Object Relational Mapping(ORM)

iBATIS Data Mapper process

What is iBATIS?

The iBATIS Data Mapper framework makes it easier to use a database with Java and .NET applications. iBATIS couples objects with stored procedures or SQL statements using a XML descriptor. Simplicity is the biggest advantage of the iBATIS Data Mapper over object relational mapping tools.

To use the iBATIS Data Mapper, you rely on your own objects, XML, and SQL. There is little to learn that you don't already know. With the iBATIS Data Mapper, you have the full power of both SQL and stored procedures at your fingertips.

Are you interested but want to know what others have said? Well, first see the various articles and books that have covered iBATIS and read some of our user feedback. Then, learn how to simple it is to use the iBATIS Data Mapper by reading our Java Tutorial or .NET Quick Start Guide!

Continuous Integration

@link
An important part of any software development process is getting reliable builds of the software. Despite it's importance, we are often surprised when this isn't done. Here we discuss the process that Matt has put into place on a major project at ThoughtWorks, a process that is increasingly used throughout the company. It stresses a fully automated and reproducible build, including testing, that runs many times a day. This allows each developer to integrate daily thus reducing integration problems.

Software development is full of best practices which are often talked about but seem to be rarely done. One of the most basic, and valuable, of these is a fully automated build and test process that allows a team to build and test their software many times a day. The idea of a daily build has been talked about a lot. McConnnell recommends it as a best practice and it's been long known as a feature of the Microsoft development approach. We agree with the XP community, however, in saying that daily builds are a minimum. A fully automated process that allows you to build several times a day is both achievable and well worth the effort.

We are using the term Continuous Integration, a term used as one of the practices of XP (Extreme Programming). However we recognize that the practice has been around for a long time and is used by plenty of folks that would never consider XP for their work. We've been using XP as a touchstone in our software development process and that influences a lot of our terminology and practices. However you can use continuous integration without using any other parts of XP - indeed we think it's an essential part of any competent software development activity.

Monday, November 07, 2005

Hibernate, quick start guide

What is Hibernate?
Hibernate is a ORM tool. ORM means object relational mapping. In laymans term, you can have a bunch of java classes(Value objects) and expect them to map directly on to the tables\columns in the database.

What can we do with Hibernate?
Lots of things. You can design the object layer and forget about your relational layer. You can create both relational and object layers and forget about data transportation.

How does Hibernate work?
By now you might have realized that the major component in hibernate or any other ORM for that matter is "M", "M" for mapping. Your task is to generate/create this mapping file. And then compile everything. So basically, you create the object layer, create a blank database, create a mapping file, create a property file with database details and command the hibernate libraries to do the mapping. You can then use the hibernate libraries in your code to play around with your objects, that are mapped on to the database.

Getting started:
  • "Road to Hibernate" is an excellent tutorial for you to get started with Hibernate. Here is the brief summary of what you will be doing:
  • Download and install hibernate(c:\program files\hibernate-3_0_5)
  • set up a work folder, something like c:\dev\hibernate
  • Copying\referencing a bunch of \lib files: ant-antlr-1.6.3.jar, asm.jar, cglib-2.1.jar, commons-collections-2.1.1.jar, commons-logging-1.0.4.jar, dom4j-1.6.jar, hibernate3.jar, jdbc2_0-stdext.jar, jta.jar, jtds-1.1.jar, log4j-1.2.9.jar
  • Create some java value objects as described in the article.
  • Create mapping file: hbm.xml
  • Create a configuration file with db connection information: hibernate.cfg.xml
  • Write code, build and execute.
The Road to Hibernate is an introductory tutorial for new users of Hibernate. We start up with a simple command line application using an in-memory database and develop it further in small steps, until we reach a full fledged J2EE-Application using Hibernate, EJBs, XDoclet and all the other nifty stuff.

This tutorial is intended to be for beginning users of Hibernate, but with advanced Java knowledge. It increases slowly in speed


@link

hsqldb - 100% Free and Fast Java Database

@link

Features Summary

  • 100% Java
  • A full RDBMS (Relational Database Management System), with the Object capabilities of Java
  • Switchable source code to support JDK 1.1.x, 1.2.x, 1.3.x, 1.4.x and above
  • Super fast startup and SELECT, INSERT, DELETE and UPDATE operations
  • Standard SQL (Structured Query Language) syntax
  • Inner and outer joins, SELECT queries as correlations in joins
  • Scalar (single value) SELECTS, correlated subqueries including IN, EXISTS, ANY, ALL
  • Views, Temp tables and sequences
  • Primary key, unique and check constraints on single or multiple columns
  • Indexes on single or multiple columns
  • ORDER BY, GROUP BY and HAVING
  • COUNT, SUM, MIN, MAX, AVG and statistical aggregate functions (also in expressions and function arguments)
  • Full support for SQL expressions such as CASE .. WHEN .. ELSE .. , NULLIF etc.
  • SQL standard autoincrement column support plus sequences
  • Transaction COMMIT, ROLLBACK and SAVEPOINT support
  • Referential Integrity (foreign keys) with full cascading options (delete, update, set null, set default)
  • Multiple schemata per database
  • Java stored procedures and functions
  • Triggers
  • Database security with passwords, user rights and roles with GRANT and REVOKE
  • Extensive set of ALTER TABLE commands allowing change of column type
  • In-memory tables for fastest operation
  • Disk based tables for large data sets
  • Text tables with external file data sources such as CSV files
  • In-memory (like applets), embedded (into Java applications) and Client-Server operating modes
  • Three client server protocols: HSQL, HTTP and HSQL-BER - can run as an HTTP web server - all with SSL option
  • Can be used in applets, read-only media (CD), inside jars, webstart and embedded applications
  • Multiple databases per JVM
  • Disk tables (CACHED TABLE) up to 8GB and text tables up to 2GB each
  • Size of each string and binary data item only limited by memory
  • Full support for PreparedStatement objects to speed up query processing
  • 95% JDBC interface support with batch statement and scrollable ResultSet functionality
  • All JDBC 1 data types supported, plus 'Object' , Boolean, Blob and Clob
  • Full JDBC 2 DatabaseMetaData and ResultSetMetaData support
  • Database dump as SQL script with or without data
  • Powerful and compact java command line and GUI tools for database management

OpenOffice: free, multiplatform and multilingual office suite

OpenOffice.org is a multiplatform and multilingual office suite and an open-source project. Compatible with all other major office suites, the product is free to download, use, and distribute.

OpenOffice.org 2.0 is the productivity suite that individuals, governments, and corporations around the world have been expecting for the last two years. Easy to use and fluidly interoperable with every major office suite, OpenOffice.org 2.0 realises the potential of open source.

With new features, advanced XML capabilities and native support for the OASIS Standard OpenDocument format, OpenOffice.org 2.0 gives users around the globe the tools to be engaged and productive members of their society.

Firefox, quick navigation using keywords

This feature is better than the bookmark feature. Basically you add a keyword to your bookmarks. Keywords are the most convenient ways to revist the websites you visit frequently.

Steps:
1. First create a bookmark to the website you visit the most.
2. Then select "bookmarks\manage bookmark" from the menu.
3. Locate the bookmark you just created.
4. Right click this boomark and see its properties.
5. under keyword add one word name for this bookmark.
6. save, click ok, and you are done.
7. Now open up a browser tab and type in your keyword in addr bar.
8. Thats it, you should see your page!

simple, effective and makes sense! I love firefox...

Sunday, November 06, 2005

Integrating JBoss with the Eclipse IDE (win32)

Following versions work together:
  • jboss-4.0.3SP1
  • Eclipse SDK 3.1.1;Build id: M20050929-0840
  • JBossIDE 1.5

Step by step guide
  1. Download and install jboss-4.0.3SP1. I used "Run Installer"
  2. Download and unzip Eclipse 3.1.1 under program files. Make sure you download and install the proper build. I have not been lucky with other builds so far.
  3. Run Eclipse.
  4. Download and install JBossIDE:
    1. Under the Eclipse IDE: Help/S.W updates/Find and install/Search for new features to install.
    2. URL: "http://download.jboss.org/jbosside/updates/development"
    3. Name: "JBossIDE 1.5 Release Candidate 1"
    4. Download and Insatall all in the list Do not do manual installation, automatic works!
  5. Setting up the default server menu: Once you are done with 4, right click any where on the IDE tool bar in eclipse and open up "Customize Perspective"; Select "Commands" tab. Select the "Default Server" check box from the list. Should be the 8th item in the list. This will enable the default server operations menu.
  6. Creating default server configuration: From the menu select Run/Debug/Jboss4.0.x. Click New button on bottom right of the drop down. Home directory: C:\Program Files\jboss-4.0.3SP1. Under the "Server Configuration" select "Default". If you see a error on top left, means you are doing something wrong. Try one of these tips:
    1. Error: could not locate tools.jar; Resolution, select a proper JDK and not JRE. The tools.jar is in the JDK folder. You have to add the JDK as an installed JRE by selecting Window->Preferences, going to the Java->Installed JREs page, adding the JDK location with a name of your choice and making it the default for your workspace. Then goto the JDK tab under your new_configuration and select the proper JDK. I am using jdk1.5.0_04.
    2. Error: no jboss.4.0.x directory; Resolution, Uninstall your jboss and reinstall it. If that doesnt work, Reinstall the eclipseIDE plugin. If still no luck, gooooogle!
    3. Error: Irritating pop up saying: Exception .metadata\.plugins\org.eclipse.debug.core\.launches. Resolution: Delete your .metadata folder that eclipse created in the workspace directory that you select at the time of launching the eclipse application. Then try 6 again.
  7. Enabling the default server menu: If you pass the above step, you are almost done! Just go under Windows/Preferences/JBoss-IDE/Launcher. Now select the default server from the drop down. This should be the server configuration you just created under step 6.
  8. Starting your server: Go back to the "Default Server" menu item, now you should be able to start/stop/etc the server.
Credits:
@devx article
@formum link for setting jdk instead of jvm

Note: Use default installation locations and settings, atleast until you get things working.

New features in J2EE 1,4

The image “http://java.sun.com/developer/technicalArticles/J2EE/new1_4/fig2.gif” cannot be displayed, because it contains errors.

Java API for XML-Based RPC (JAX-RPC), aka Java Web Services
You can use the Java API for XML-based RPC (JAX-RPC) to build Web applications and Web services, incorporating XML-based RPC functionality according to the SOAP 1.1 specification.
@link

JACC, Java Authorization Contract for Containers
The Java Authorization Contract for Containers (Java ACC) specification (JSR-115) defines new java.security.Permission classes to satisfy the Java 2 Platform, Enterprise Edition (J2EE) authorization model. The Java ACC specification defines the binding of container access decisions to operations on instances of these permission classes.
@link

Java API for XML Registries (JAXR) Overview
The Java API for XML Registries (JAXR) provides a uniform and standard Java API for accessing different kinds of XML Registries. An XML registry is an enabling infrastructure for building, deploying, and discovering Web services.

Currently there are a variety of specifications for XML registries including, most notably, the ebXML Registry and Repository standard, which is being developed by OASIS and U.N./CEFACT, and the UDDI specification, which is being developed by a vendor consortium.

JAXR enables Java software programmers to use a single, easy-to-use abstraction API to access a variety of XML registries. Simplicity and ease of use are facilitated within JAXR by a unified JAXR information model, which describes content and metadata within XML registries.
@link

Java Management Extensions (JMX)
Java Management Extensions (JMX) technology provides the tools for building distributed, Web-based, modular and dynamic solutions for managing and monitoring devices, applications, and service-driven networks. By design, this standard is suitable for adapting legacy systems, implementing new management and monitoring solutions, and plugging into those of the future.
@link

Mgmt: J2EE Management Specification
The J2EE Management specification (JSR 077) includes standard mappings of the model to the Common Information Model (CIM), to an SNMP Management Information Base (MIB), and to the Java object model through a server resident Enterprise JavaBeans (EJB) component, known as the J2EE Management EJB Component (MEJB). The MEJB provides interoperable remote access to the model from any standard J2EE application.
@link
@javaWorld article

Thursday, November 03, 2005

Fastest JDBC driver for SQLServer: jTDC

jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000 and 2005) and Sybase (10, 11, 12). jTDS is based on FreeTDS and is currently the fastest production-ready JDBC driver for SQL Server and Sybase. jTDS is 100% JDBC 3.0 compatible, supporting forward-only and scrollable/updateable ResultSets, concurrent (completely independent) Statements and implementing all the DatabaseMetaData and ResultSetMetaData methods. Check out the feature matrix for more details.

Quite a few of the commercial JDBC drivers out there are based on jTDS (or FreeTDS), even if they no longer acknowledge this. jTDS has been tested with virtually all JDBC-based database management tools and is the driver of choice for most of these (recommended for DbVisualizer and SQuirreL SQL, distributed with Aqua Data Studio and DataDino). jTDS is also becoming a common choice for enterprise-level applications: it passes both the J2EE 1.3 certification and Hibernate test suites, and is recommended for JBoss, Hibernate, Atlassian JIRA and Confluence and Compiere.

@link

Troubleshooting tool, find dependencies: Dependency Walker

@link
Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules. Another view displays the minimum set of required files, along with detailed information about each file including a full path to the file, base address, version numbers, machine type, debug information, and more.

Dependency Walker is also very useful for troubleshooting system errors related to loading and executing modules. Dependency Walker detects many common application problems such as missing modules, invalid modules, import/export mismatches, circular dependency errors, mismatched machine types of modules, and module initialization failures.

Dependency Walker runs on Windows 95, 98, Me, NT, 2000, XP, and 2003. It can process any 32-bit or 64-bit Windows module, including ones designed for Windows CE. It can be run as graphical application or as a console application. Dependency Walker handles all types of module dependencies, including implicit, explicit (dynamic / runtime), forwarded, delay-loaded, and injected. A detailed help is included.

Dependency Walker is completely free to use. However, you may not profit from the distribution of it, nor may you bundle it with another product.

Tuesday, November 01, 2005

A free version control tool from Apache, subVersion

step by step book
a useful forum link
configuring http, step by step
Setting Up a Secure Apache 2 Server
Most useful resource if you are setting up https for apache
SSL Securing apache server for windows 2003

What is WebDAV?

Briefly: WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.

@link

XMLHttpRequest object

The XMLHttpRequest object is a handy dandy JavaScript object that offers a convenient way for webpages to get information from servers without refreshing themselves.

The benefit to end users is that they don't have to type as much and they don't have to wait as long. For example, having the user's city and state show up in a webpage automatically after the ZIP code has been typed in is a big time saver.

Although the XMLHttpRequest object might sound complex and different from any other JavaScript object you have ever used, it really isn't. A good way to think of the XMLHttpRequest object is as you would think of the JavaScript Image object. As we know, with the Image object you can dynamically specify a new URL for the image source without reloading the page. Similarly with the XMLHttpRequest object, you can dynamically specify a URL to get some server data without reloading the page.


@link
@wiki-xmlHTTP
@apple
XMLHttpRequest & Ajax Working Examples