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 |
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.
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:
You can specify the properties in the build.properties file.
You can specify the properties explicitly when issuing the command.
You can specify properties globally in the build.properties file, and override them selectively by specifying those to be overridden when issuing the command.
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 |
You can configure the repository location using the command-line parameter commandline.rep.dir. The default value is localrepository.
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). |
Ensure there are no leading or trailing spaces in the values you enter for variables.
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 |
Install Apache Ant, version 1.6 or later, on your computer. You can download this program from the following URL:
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
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 |
You must set this variable in the command window, in the directory in which you will be running the command.
Locate the file build.properties in your commandlinecodegen directory.
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= |
Fill in the property values as described in Table 1–1 (optional properties may be left blank).
Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:
ant -propertyfile build.properties |
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}" |
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.
Locate the file build.properties in your commandlinecodegen directory.
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= |
Fill in the property values as described in Table 1–1.
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}" |
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.
The Export command works for ksh and bash. For csh, use setenv instead.
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 |
Locate the file build.properties in your commandlinecodegen directory.
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= |
Fill in the property values as described in Table 1–1 (optional properties may be left blank).
Run commandline codegen by issuing the following command from the command-line prompt in your commandlinecodegen directory:
sh ant –propertyfile build.properties |
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 |
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}" |
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.
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 |
Locate the file build.properties in your commandlinecodegen directory.
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= |
Fill in the property values as described in Table 1–1.
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.