JavaGen.com

JavaGen Setup Guide

This page guides you through the installation of Java, Ant, Maven, the JBoss J2EE application server and JAM (JavaGen Ant Modules). If you're using a different J2EE application server, you can modify the installation accordingly. After completing the setup, the tutorials page guides you through the application build and code generation process.

Table of Contents:

Prerequisites - Really Basic Stuff

Skill Prerequisites

The prerequisites are a working knowledge of Java, XML and familiarity with Ant. Also needed are file management skills using the operating system's command-line console. J2EE Application Server, XDoclet, SQL, database management, and UML technologies can be learned on a need-to-know basis as the project progresses.

Operating Systems Prerequisites

To do software development, a modern operating system is needed, such as the following:

  • Windows NT, Windows 2000, or Windows XP
  • A Linux flavor with good Java support like Red Hat.
  • Mac OS X
  • Sun Solaris OS

Older operating systems such as Windows 95, Windows 98, Windows ME or Mac OS 7/8/9 will not be adequate.

The computer should have at least 1 GBytes available on the hard drive, at least 250 MBytes of memory, and a reasonably fast (500 MHz +) clock speed.

Tips

To avoid errors, be methodical in typing, or better yet, cut-and-paste the directory locations when configuring the environmental variables while verifying each step. Depending upon the existing setup, some steps may be skipped. Look for the verification instructions and let the results guide you.

Fast Track - Experienced Developers

Experienced developers who already have the prerequisite programs installed (Java 1.3+, Ant 1.6+, Maven 1.0-rc1+ and JBoss 3.x+) can go directly to the JAM Installation.

To verify you have the proper setup, type set on windows machines or env on Unix machines in the console. Here is roughly how the environmental variables should look using JBoss on a Windows machine (your directories will be different):

	JAVA_HOME=C:\dev-tools\j2sdk1.4.0_03
	ANT_HOME=C:\dev-tools\apache-ant-1.6.1
	MAVEN_HOME=C:\dev-tools\maven-1.0-rc1
	JAM_HOME=C:\dev-tools\javagen-ant-modules-2.0
	JBOSS_DIST=C:\dev-tools\jboss-3.0.4_tomcat-4.1.12
	
	Path=%JAVA_HOME%\bin;ANT_HOME%\bin;%MAVEN_HOME%\bin;...

Unix Setup

Installing Java on Unix

You need both the Java Runtime Environment (JRE) and the Java Development Kit (JDK), versions 1.3 or newer. The command java -version will verify if you have the JRE. The command javac will verify if you have the JDK. The simplest way to ensure that your system has both is to install the J2SE package, either from your distribution's normal sources or directly from java.sun.com. Note: This step may require root privileges, but the remaining steps can all be run as a normal user.

You must set the environment variables as specified below before the Java installation is complete.

Installing Ant on Unix

You need Ant 1.6 or newer; older versions will not work. Download and unpack it in your home directory:

	tar -xzvf apache-ant-1.6.1-bin.tgz

To verify Ant is installed, go to Ant's bin directory and type ant. You should see the following:

	Buildfile: build.xml does not exist!
	Build failed

You must set the environment variables as specified below before the Ant installation is complete.

Installing Maven on Unix

Download Maven 1.0-rc1 or newer and unpack it into your home directory:

	tar -xzvf maven-1.0-rc2.tgz

You must set the environment variables as specified below before the Maven installation is complete.

To verify your installation type, maven -v in the console and you should see:

	 __  __
	|  \/  |__ _Apache__ ___
	| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
	|_|  |_\__,_|\_/\___|_||_|  v. 1.0-rc2
	...
Installing JBoss on Unix

You need the JBoss (>=3.2) Application server. You can get this from jboss.org if your distribution doesn't have it packaged. JBoss can either be installed system wide or in your home directory, which is recommended for testing. In either case, keep track of where the /jboss-3.x.x/bin directory gets installed.

To test your JBoss installation, open a console, cd to the /jboss-3.x.x/bin directory and type, ./run.sh You should see a number of messages, ending with something like:
19:31:19,206 INFO [Server] ... JBoss Started in 0m:39s:237ms.

Open a web browser and enter the address: http://localhost:8080/jmx-console/index.jsp and you should see the JMX Console Web Application with links to all JBoss's installed components. Issue ctrl-c from the console in which JBoss is running to quit.

Download & Extract JAM on Unix

To install JAM, download the latest version and unpack it in your home directory:

	tar -xzvf JavaGen-Ant-Modules-2.0.tgz

Finish the Unix installation steps, then go to the JAM installation to complete the install process.

Setting Environment Variables on Unix

Next, set up your environment and path for the installed components. JavaGen needs five environment variables set, JAVA_HOME, ANT_HOME, MAVEN_HOME, JAM_HOME and JBOSS_DIST. All five of these variables should point to the base directories of these programs (e.g. there should be bin sub-directory under the directories specified).

Setting environment variables is somewhat distribution/shell specific. Using the bash shell as an example, the command is:

	export JAVA_HOME=/usr/lib/j2se/1.4
	export ANT_HOME=/home/username/apache-ant-1.6.1
	export MAVEN_HOME=/home/username/maven-1.0-rc1
	export JAM_HOME=/home/username/javagen-ant-modules-2.0
	export JBOSS_DIST=/home/username/jboss-3.2.2
Note that you may have to replace the values in the example with the directories which are correct for your setup.

The bin sub-directories of four of the directories specified above should be appended to the PATH environment variable (JAM doesn't have a bin directory). Again, the exact command is shell specific. Using the bash shell for an example, the command is:

	PATH=${PATH}:${JAVA_HOME}/bin:${ANT_HOME}/bin:${MAVEN_HOME}/bin:${JBOSS_DIST}/bin

You can check that the environment variables and path are set correctly by issuing the command env. Note that you may have to issue these commands in each console you wish to use JavaGen. To have them automatically set, append the lines to your shell config file (for example /home/username/.bashrc), log out and log back in.

Windows Setup

Installing Java on Windows

You need a current (1.3 or newer) version of both the Java Runtime Environment (JRE) and the Java Development Kit (JDK). The command java -version will verify if you have the JRE. The command javac will verify if you have the JDK. The simplest way to ensure that your system has both is to install the J2SE package from java.sun.com Note: This step may require Administrator privileges, but the remaining steps can all be run as a normal user.

You must set the environment variables as specified below before the Java installation is complete.

Installing Ant on Windows

You need Ant 1.6 or newer, older versions will not work. Download and unzip it into your development tools directory.

You must set the environment variables as specified below before the Ant installation is complete.

To verify Ant is installed, go to Ant's bin directory and type ant. You should see the following:

	Buildfile: build.xml does not exist!
	Build failed
Installing Maven on Windows

Download Maven 1.0-rc2 or newer and unzip it into your development tools directory.

You must set the environment variables as specified below before the Maven installation is complete.

To verify your installation, type maven -v in the console and you should see:

	 __  __
	|  \/  |__ _Apache__ ___
	| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
	|_|  |_\__,_|\_/\___|_||_|  v. 1.0-rc2
	...
Installing JBoss on Windows

You need the JBoss Application server, version 3.2 or newer. You can get this from jboss.org. Unzip JBoss into your development tools directory.

To test your JBoss installation, open a console, cd to the \jboss-3.x.x\bin directory and type run You should see a number of messages, ending with something like:
19:31:19,206 INFO [Server] ... JBoss Started in 0m:39s:237ms.

Open a web browser and enter the address: http://localhost:8080/jmx-console/index.jsp and you should see the JMX Console Web Application with links to all JBoss's installed components. Issue ctrl-c from the console in which Jboss is running to quit.

Download & Extract JAM on Windows

Download the latest version of JAM from the download page: http://www.javagen.com/download.jsp, and unzip into your development tool directory using a zip utility like WinZip.

Setting Environment Variables on Windows

Next, set up your environment and path for the JavaGen components. JavaGen needs five environment variables set: JAVA_HOME, ANT_HOME, MAVEN_HOME, JAM_HOME and JBOSS_DIST. All five of these variables should point to the base directories of these programs (e.g. there should be \bin and \lib sub-directories under the directories specified):

	set JAVA_HOME=c:\dev-tools\j2se-1.4
	set ANT_HOME=c:\dev-tools\apache-ant-1.6.1
	set MAVEN_HOME=c:\dev-tools\maven-1.0-rc1
	set JAM_HOME=c:\dev-tools\javagen-ant-modules-2.0
	set JBOSS_DIST=c:\dev-tools\jboss-3.2.2
Note that you may have to replace the values in the example with the correct directories for your setup.

The bin sub-directories of four of the directories specified above should be appended to the PATH environment variable (JAM does not have a bin directory):

	set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;%MAVEN_HOME%\bin;%JBOSS_DIST%\bin

You can check that the environment variables and path are set correctly by issuing the command set. Note that you may have to issue these commands in each console you wish to use JavaGen. To have them automatically set is slightly different depending upon which version of windows you're using. For Windows 2000, select System from the Control Panel (the menu sequence is: Start/Settings/Control Panel/System). You should be looking at the System Properties window. Select the Advanced tab. Then click on Environmental Variables.... Within the Environmental Variables window you can set each variable either for the current user or the system (i.e. machine) as a whole. To verify your settings, open a new console and type set as above.

JAM Installation

To install JAM (JavaGen Ant Modules) you should have completed the platform specific steps above, including downloading and extracting the latest version of JAM from http://www.javagen.com/download.jsp. Minimally, you need Ant 1.6 up and running (older versions of Ant will not work) and the MAVEN_HOME environmental variable set. You will also need a connection to the internet to access Maven's central repository. Change to the install subdirectory of JAM and type: ant. This runs the JAM install Ant script which does the following:

  1. Verifies Maven is installed.
  2. Copies all the needed open-source libraries from http://www.ibiblio.org/maven.
  3. Copies a few JavaGen jars and a few files missing from Maven's repository.
  4. Puts an empty copy of props-user.xml in the ${user.home}/.ant directory.
  5. Copies the maven-javagen-ant-plugin to Maven's plugin directory.
  6. Puts a copy of JUnit in Ant's runtime directory (${user.home}/.ant/libs) avoiding some future debugging issues. Note: you should verify that there is only one copy of JUnit at this location.
  7. Completes by printing some useful properties.

You will see a few error messages; this is normal, resulting from files that are not found in Maven's central repository (In particular, j2ee-1.3.1.jar is not there because of licensing issues - see Installing J2EE Library).

To verify everything is setup properly, go to JAM's install directory and type ant setup. You should see the JavaGen settings output starting with:

     [echo] + ==\_/=======J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S============ +
     [echo] +  \(_)/                                                        +
     [echo] +  -(_)-           Congratulations JAM is Installed             +
     [echo] +  /(_)\                                                        +
     [echo] + ============================================================= +
	 ...

J2EE Library Installation

Due to licensing issues, the J2EE API's can not be stored in Maven's central repository. You have to download this code directly from Sun's site and place it in the repository manually, using proper Maven naming conventions. Note: You may already have this code lying around (it is included in one form or another with most Java IDEs and J2EE application servers), however to keep things simple we'll just explain how to get it from Sun. Download the J2EE code from http://java.sun.com/j2ee/sdk_1.3 and extract it into your development tools directory. Go to the lib directory of the J2EE distribution where you'll find the j2ee.jar file. Copy this jar file to the j2ee/jars sub-directory within the Maven local repository and rename it to reflect the proper J2EE version. Here is an example of the complete path of the copied file on a Windows machine:

	C:\Documents and Settings\username\.maven\repository\j2ee\jars\j2ee-1.3.1.jar

If you don't know where the local repository is located, go to JAM's install directory and type ant setup. The value of the maven.repo property indicates the repository location.

If you did everything correctly, the J2EE APIs can be included in your classpath by including the following dependency entry in your Maven POM file:

    <dependency>
      <groupId>j2ee</groupId>
      <artifactId>j2ee</artifactId>
      <version>1.3.1</version>
    </dependency>

Congratulations!

You're ready to start using JAM and JavaGen. Next stop - the tutorial page.