![]() |
The Build tool provided in Studio is used to compile individual files and build multiple files. The EJB modules and Web modules in the desk are always in a "ready-to-deploy" state. The J2EE applications developed can be deployed properly once they have been compiled. This chapter helps understand how to build applications.
The Build Tool is used to compile all Java source code, all JSP files, Servlets and archive files in Studio. Studio provides three ways to compile files in Studio:
Compile is used to compile individual files. Both Build and Clean Build options are provided on the modules in the desk tree.
To configure the properties that the Build tool uses to compile and execute the specified files, use Build Settings.
The settings can be specified separately for the desk, EJB modules, Web modules and Java Modules. Changing the Build Settings of the specific folders can overwrite the settings specified at the desk level.
Desk Root on the Explore Panel > Right Click > Properties > Build tab
Clicking on this brings up the dialog box with the Build Settings tab where the following build properties can be set:
The order of the Classpaths can be edited using the buttons with the "up arrow" and "down arrow" icons.
Java Module/EJB module/Web module on the Explore Panel > Right Click > Properties
Clicking on this brings up the Properties dialog box. Click on the Build tab to view and modify the following build settings:
Classpath entries for module, which are not present in the classpath entries for the desk are displayed with white background and black text. Entries in the classpath that do not exist in the file system are shown with white background and red text.
Creating a new module in the desk sets the Class path of the module with the following information:
The order of the Classpaths can be edited using the buttons with the "up arrow" and "down arrow" icons.
The following sections describe how to use the Studio Build Tool to compile and build applications.
Build > Compile
Compiles the selected file and displays all the errors in the output panel if any. For JSP Pages that use Taglib JARs to be compiled, the URL must point to the location of the taglib JAR being used.
Build > Build
Builds the stipulated format by compiling all the files in the application. While building the files, it does not check for the dependencies, and therefore may not show all the compilation errors during compilation. It is faster than Clean Build.
All the errors and the warnings are displayed in the output panel. Right clicking on the appropriate node > Build also allows you to build the application.
Right Click on the specific folder > Right Click > Clean Build
Clean Build compiles all the files contained in the folder where Clean Build is executed, while Build checks the time stamp of the class files and then compiles the files only if required. Compiling the files in this way takes longer than compiling the files using Build, but is more reliable.
Build is faster than Clean Build and is sufficient in most cases. If you have changed the interfaces, then Clean Build is advised as it compiles all the files and the errors are shown at compile time instead of runtime. All the errors and the warnings are displayed in the output panel.
In the Build tab of the Output window, double click anywhere on the error description. This positions the cursor at the appropriate place in the display panel, in order to go to the previous and next errors. The keyboard shortcuts for these are Ctrl + Shift + Z, and Ctrl + Shift + A respectively.
Build > Stop Build
Stops the Build process by stopping the currently executing tool. While the building process is on in the background, Studio can be used as usual.
The Build tool compiles and recompiles and recreates files without the user having to remember what changed and in what order to compile the files. It also allows you to develop applications such that it is more portable, and on multiple platforms.
It is one of the most important tools in Studio. Without building files in an application, it cannot be deployed.
Before building the application, the settings for the same can be set. The class files are by default placed in the following locations:
|
Node in the Tree
|
Location
|
|---|---|
|
Desk
|
Studio/My Desk
|
|
Java Module
|
Studio/My Desk/classes/Java Module
|
|
EJB module
|
Studio/My Desk/classes/EJB module
|
|
Web module
|
Studio/My Desk/Web module/web-inf/classes
|
The user can change the default settings of the class files only for Java Modules. Some editable fields are:
To understand how the build tool functions browse through the cases given below. These cases are implications of the Build tool rules.
The desk comprises one folder. The folder can either be a Java Module or an EJB module. The location of the module in the file system is the same as that in the desk. The Build tool, in such a case compiles all the files in the module and then builds the EJB module or the Java Module with the specified build settings.
The desk comprises two folders where one is a Java Module and the other is an EJB module. Both the folders share the same source root in the disk. Both the Java Module and the EJB module share one or more files/Beans.
The Build tool, in this case compiles a file/bean as many times as it has been added to the desk. In the above scenario as the same file/bean is shared by both the folders, compiling the file/bean in one-folder compiles them in the other folder automatically. Compiling a bean also compiles the helper class provided the user had checked the sourcepath option in Build settings. Once both the Java Module and EJB module get built with the specified build settings, the EJB module is ready to be deployed.
The desk comprises of two folders where one is a Java Module and the other is an EJB module. Both the folders have different source roots in the disk.
Since the file, which is being depended on, does not belong to the same source root, it has to be explicitly added to the specific user class path. Both the Java Module and EJB module then get build with the specified build settings.
| Pramati Technologies © Copyright |
|