Deploying Java CAPS Projects

Building an Application File

The end product of the Project design process is an application file that can be deployed to an application server. This enterprise archive (.ear) file contains a collection of .jar files, classes, and resources. In the case of a web application, the corresponding web archive (.war) file contains a group of .jar files, classes, and resources that can be packaged and accessed as a single servlet context.

Once a Deployment Profile has been defined for your Project, you can build the .ear or .war file by clicking the Build button in the Deployment Editor toolbar. You can also generate an .ear file from the command line, without having NetBeans running.

The resulting .ear or .war file is stored in the following directory:


CAPS_install_dir\.netbeans\caps\builds\DeploymentNameProjectName\logicalhost\appserver

Note –

By default, the .ear file does not contain the associated Java source files. For the Java source files to appear in the .ear file, you need to set the value of the NetBeans run.mode property to debug before building the file. You do this by setting a command-line switch in the following file:


CAPS_install_dir\netbeans\etc\netbeans.conf

Add “-J-Drun.mode=debug” to the series of entries following netbeans_default_options=. Note that the resulting .ear file can be quite large.


Building an Application File From the Command Line

You can generate an .ear file from the command line, without having the NetBeans IDE running, by using the commandline codegen tool, which you must download from the Repository using the Java CAPS Installer. When using this tool, you have three options for specifying the build properties for the .ear file:

  1. You can specify the properties in the build.properties file.

  2. You can specify the properties explicitly when issuing the command.

  3. You can specify properties globally in the build.properties file, and override them selectively by specifying those to be overridden when issuing the command.


Note –

All relevant components must be saved in the NetBeans IDE prior to running commandline codegen.


By default, the resulting .ear file will be located in the following directory:


commandlinecodegen-install\localrepository\DEST\builds\ear-file\logicalhost\appserver

Note –

You can configure the repository location using the command-line parameter commandline.rep.dir. The default value is localrepository.


Table 1–1 Commandline Codegen Properties

Property Name 

Description 

commandline.rep.url 

Repository URL (required). The format is: http://host:port/repositoryname

commandline.rep.user 

Repository user name (required). 

commandline.rep.pass 

Repository user password (required). 

commandline.rep.dir 

Repository root directory (required). The default value is localrepository.

commandline.rep.projectName 

Project name (required). 

commandline.rep.projectDeployName 

Deployment Profile name (required). 

commandline.rep.projectDeploymentTag 

Project snapshot name (optional). 

commandline.rep.projectBranchName 

Repository Branch for the Project (optional). 


Note –

Ensure there are no leading or trailing spaces in the values you enter for variables.


ProcedureTo set up your system to use commandline codegen

  1. Set the JAVA_HOME environmental variable on your computer to the location where JDK version 1.5 is installed, for example:


    set JAVA_HOME=c:\Program Files\Java\jdk1.5.0_14
  2. Install Apache Ant, version 1.6 or later, on your computer. You can download this program from the following URL:

    http://ant.apache.org/bindownload.cgi

  3. Log in to the Java CAPS Uploader, click the Downloads tab, and install commandline codegen. For additional information, see Installing Java CAPS Components Using the Java CAPS Uploader in Using the Java CAPS 6 Installation GUI

  4. At the command-line prompt, set the ANT_HOME environmental variable, for example:


    set ANT_HOME=c:\Program Files\Apache\apache-ant-1.6.5

    Note –

    You must set this variable in the command window, in the directory in which you will be running the command.


Windows Platform Procedures

ProcedureTo build an application file based on a property file only (Windows)

  1. Locate the file build.properties in your commandlinecodegen directory.

  2. Open the file using a text editor such as Notepad. The contents are as follows:


    commandline.rep.url=http://host:port/repositoryname
    commandline.rep.user=
    commandline.rep.pass=
    commandline.rep.dir=localrepository
    commandline.rep.projectName=
    commandline.rep.projectDeployName=
    commandline.rep.projectDeploymentTag=
    commandline.rep.projectBranchName=
  3. Fill in the property values as described in Table 1–1 (optional properties may be left blank).

  4. Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:


    ant -propertyfile build.properties

ProcedureTo build an application file by passing parameters in the command line only (Windows)

  1. Run commandline codegen by issuing the following command from the command prompt in your commandlinecodegen directory (see Table 1–1):


    ant "-D(propertyname1)=(propertyvalue1)" "-D(propertyname2)=
    (propertyvalue2)" … "-D{propertynameN}={propertyvalueN}"

    Note –

    When using the command-line properties method, you must specify values for all required properties. You also may specify values for any optional properties as is appropriate.


ProcedureTo build an application file based on both a property file and by passing parameters in the command line (Windows)

  1. Locate the file build.properties in your commandlinecodegen directory.

  2. Open the file using a text editor such as Notepad. The contents are as follows:


    commandline.rep.url=http://host:port/repositoryname
    commandline.rep.user=
    commandline.rep.pass=
    commandline.rep.dir=localrepository
    commandline.rep.projectName=
    commandline.rep.projectDeployName=
    commandline.rep.projectDeploymentTag=
    commandline.rep.projectBranchName=
  3. Fill in the property values as described in Table 1–1.

  4. Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:


    ant -propertyfile build.properties "-D{propertyname1}={propertyvalue1}"
    "-D{propertyname2}={propertyvalue2}" … "-D{propertynameN}={propertyvalueN}"

    Note –

    When using a combination of a property file and command-line properties, the command-line properties override those specified in the property file. You need to list only those properties that you want to override.


UNIX Platform Procedures


Note –

The Export command works for ksh and bash. For csh, use setenv instead.


ProcedureTo build an application file based on a property file only (AIX/Linux/MacOS/Solaris)

  1. At the command prompt, run the commands:


    Export ANT_HOME=path
    Export JAVA_HOME=path
    dos2unix ant ant
    dos2unix build.xml build.xml
    dos2unix build.properties build.properties
  2. Locate the file build.properties in your commandlinecodegen directory.

  3. Open the file using a text editor. The contents are as follows:


    commandline.rep.url=http://host:port/repositoryname
    commandline.rep.user=
    commandline.rep.pass=
    commandline.rep.dir=localrepository
    commandline.rep.projectName=
    commandline.rep.projectDeployName=
    commandline.rep.projectDeploymentTag=
    commandline.rep.projectBranchName=
  4. Fill in the property values as described in Table 1–1 (optional properties may be left blank).

  5. Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:


    sh ant –propertyfile build.properties

ProcedureTo build an application file by passing parameters in the command line only (AIX/Linux/MacOS/Solaris)

  1. At the command prompt, run the commands:

    At the command prompt, run the commands:


    Export ANT_HOME=path
    Export JAVA_HOME=path
    dos2unix ant ant
    dos2unix build.xml build.xml
    dos2unix build.properties build.properties
  2. Run commandline codegen by issuing the following command from the command prompt in your commandlinecodegen directory (see Table 1–1):


    sh ant "-D{propertyname1}={propertyvalue1}" "-D{propertyname2}=
    {propertyvalue2}" … "-D{propertynameN}={propertyvalueN}"

    Note –

    When using the command-line properties method, you must specify values for all required properties. You also may specify values for any optional properties as is appropriate.


ProcedureTo build an application file based on both a property file and by passing parameters in the command line (AIX/Linux/MacOS/Solaris)

  1. At the command prompt, run the commands:


    Export ANT_HOME=path
    Export JAVA_HOME=path
    dos2unix ant ant
    dos2unix build.xml build.xml
    dos2unix build.properties build.properties
  2. Locate the file build.properties in your commandlinecodegen directory.

  3. Open the file using a text editor such as Notepad. The contents are as follows:


    commandline.rep.url=http://host:port/repositoryname
    commandline.rep.user=
    commandline.rep.pass=
    commandline.rep.dir=localrepository
    commandline.rep.projectName=
    commandline.rep.projectDeployName=
    commandline.rep.projectDeploymentTag=
    commandline.rep.projectBranchName=
  4. Fill in the property values as described in Table 1–1.

  5. Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:


    sh ant -propertyfile build.properties "-D{propertyname1}={propertyvalue1}"
     "-D{propertyname2}={propertyvalue2}" … "-D{propertynameN}={propertyvalueN}"

    When using a combination of a property file and command-line properties, the command-line properties override those specified in the property file. You need to list only those properties that you want to override.