Running your Ant script

Once you have saved the settings for your J2C Java™ bean and your data binding classes in an Ant file, you can run this Ant script separately.
Running your ant script from the workspace
  1. Right-click on the Ant file that you want to run.
  2. Click Ok.
  3. Choose Run as > Ant build...
  4. In the launch attributes window, open the JRE tab and select Run in the same JRE as the Workspace. Click Apply and then Run.
    Note: You only need to set the JRE the first time you run the ant script. When you run it the next time, simply invoke Run as > Ant Build .
  5. .
Running your ant script from the command line

Once generated or modified, your Ant scripts can be executed without launching the IDE; this is called the Headless mode. To run the Ant script, you simply invoke the antRunner application, passing the Ant file as argument.

  1. Create a simple batch file, Test.bat, for running the generated Ant script in headless mode
    echo off
    setlocal
    
    set ECLIPSE=<installdir>\IBM\SDP70\
    set WORKSPACE=\%ECLIPSE%\MyWorkspaceANT
    set BUILDFILE=<installdir>\developerwork\Customer.xml
    
    rem set JAVA_HOME=<installdire>\Programs\jdksun1.4.2
    set JAVA_HOME=%ECLIPSE%\jdk\jre
    set PATH=%JAVA_HOME%\bin;%PATH%
    set CLASSPATH=%JAVA_HOME%\lib;%CLASSPATH%
    
    
    java -cp %ECLIPSE%\startup.jar org.eclipse.core.launcher.Main -clean -data %WORKSPACE% 
    
     -application org.eclipse.ant.core.antRunner -buildfile %BUILDFILE%
    
    Where:
        ECLIPSE environment variable defines the path to the eclipse folder within RAD
        WORKSPACE defines the path where the workspace will be created
        BUILDFILE is the path to your generated Ant script you would like to run.
    
    You can modify the variables in the batch file to fit your environment:
    • Replace ECLIPSE with your eclipse root
    • Replace WORKSPACE with the workspace name and location
    • Replace BUILDFILE with your J2C Ant script
  2. Open a command window, and invoke Test.bat from the command line.
  3. After the Test.bat is completed sucessfully, you can bring up your workspace and all the project and data binding file will be created.
Known limitation of the Ant script: Cannot Locate RAR
If you already have the connector project created in your workspace for a particular Resource Adapter, when you go through the J2C Java Bean wizard, the Resource Adapter will not be imported again. When you generate the Ant script, the script has no way of figuring out the location of the resource adapter since the connector project does not provide such information. If the ra.file value equals cannotlocaterar, then you will need to manually add the resource adapter location to the generated J2C Java bean ant script yourself. This is a known limitation. Your Ant file will contain the line: property name="ra.file" value="Cannot Locate RAR "
<target name="Init1">
<property name="debug" value="true"/>
<property name="project1" value="project111"/>
<property name="ra.project" value="cicseci602"/>
<property name="ra.runtime" value="WebSphere Application Server v6.1"/>
<property name="ra.file" value="Cannot Locate RAR "/>
</target> 

Feedback