The JBuilder compiler has full support for the Java language, including inner classes and JAR files. You can compile from within the integrated development environment (IDE).
bmj and bcj are features of JBuilder Professional and Enterprise.
With JBuilder Professional and Enterprise, you can also compile from the command line using bmj (Borland Make for Java) or bcj (Borland Compiler for Java).
A Java compiler reads Java source files, determines which additional files need to be compiled, and produces the Java program in the form of .class files containing bytecodes that are the machine code for the Java Virtual Machine (VM).
Compiling produces a separate .class file for each class declaration and interface declaration in a source file. When you run the resulting Java program on a particular platform, such as Windows NT, the Java interpreter for that platform runs the bytecodes contained in the .class files.
For additional general information about compiling in Java, see the overview of the compiler that comes with the Java Development Kit (JDK), "javac - The Java programming language compiler."
When you compile source files for the first time, a dependency file is automatically created for each package and is placed in the output directory along with the class files. The dependency file contains detailed information about which class uses which for all the classes in that package. This file has an extension of .dependency.
Dependency files must be located in the Class Path so the compiler can find them. When you compile from within the IDE, the Class Path is correctly set by default. For information on how the Class Path is constructed, see the "Class Path" section in the "Creating and managing projects" chapter.
If you compile from the command line, you might need to set the CLASSPATH
environment variable. For more information, see "Setting the CLASSPATH environment variable for command-line tools."
Smart Dependencies Checking is used by the compiler in the IDE and by the bmj command-line make but not by the bcj command-line compiler. (bmj and bcj are available in JBuilder Professional and Enterprise.)
The following parts of a program can be compiled:
To understand how JBuilder locates files to compile the program, see
"How JBuilder constructs paths" and "Where are my files?"
The selected node can be a project, package, or .java file. Making a package or project includes all the .java files within the package or project, including those within nested packages.
An "outdated" .class file is one that was not generated by compiling the current version of its .java source file.
The imported files that are checked and compiled include all recursively imported files (that is, imported files of imported files) except for files that are not in packages in the current project, such as files in packages that are marked "stable."
Make is faster than Rebuild, once you have done the initial compiling. The Make command is generally preferred over Rebuild.
To Make a node, select the node in the project pane, and choose Make <node name>.
Issuing File|Save and then Make on a file won't necessarily cause the file to be recompiled, because the date-time stamp reflects the last edit action, not the last save. To force a recompile, either use Rebuild <node name>, or make a change to the file in the editor before saving it. For example, type a space and then a backspace.
The selected node can be a project, package, or .java file. Rebuilding a package or project includes all the .java files within the package or project, including those within nested packages.
The imported files that are compiled include all recursively imported files (that is, imported files of imported files) except for files in the stable packages that are not part of the project.
To Rebuild a node, select the node in the project pane, and choose Project|Rebuild <node name>.
This is a feature of JBuilder Professional and Enterprise.When the Enable Source Package Discovery And Compilation option is enabled, all packages in the project's source path automatically appear in the project pane. When compiling with this option on, any packages that contain Java files are automatically compiled and resources in these packages are automatically copied to the project's out path. Packages that contain only resources are also copied to the out path.
To minimize the number of package nodes listed, JBuilder automatically displays a subset of the packages in your project. Even though some source packages may not be listed at the top level of your project, JBuilder still compiles them and copies their resources.
This option is found on the General page of the Project Properties dialog box and is on by default. You can also control the level of packages displayed in the project pane by changing the value of Deepest Package Exposed. For more information on this feature, press the Help button on the General page.
.jpr
or .jpx
project node in the project pane.
To locate the line of code containing the error, expand the Errors
folder in the structure pane and double-click the error. The line
containing the error is highlighted in the editor.
Error messages also appear on the Compiler tab in the message pane during compiling. Select an error message and press F1 for Help. Use the arrow keys to navigate through compiler error messages. Click an error message to highlight the code in the open file.
See also:
About error and warning messages
"Error Messages" where error messages are listed by number
Additionally, check the Required Libraries list on the Paths page. If one or more of the libraries is highlighted in red, it is not defined for your installation of JBuilder. Double-click the library name to define it. Then, try to recompile the project.
To set default paths for new projects (to avoid future potential problems), use the Default Project Properties dialog box (Project|Default Project Properties). See the "Setting project properties" and "How JBuilder constructs paths" topics in the "Creating and managing projects" chapter for more information.
The first time you build a project, all the available .java files in a package directory will be verified and compiled. If you have temporary sources that you do not want to compile, you should use another extension besides .java. For example, if the project contains an old version of a file you are working on and that file contains another definition of the same class, you'll get a "duplicate class definition" error. This checking prevents subtle problems that would be difficult to locate.
If you are using a class library that is partly inconsistent and you don't have the sources to rebuild the library, you can avoid verifying all classes of the package, and check only the classes that are actually used, by specifying the -nomakestable compiler option on the command line. In the IDE, check the Make Stable Packages option on the Build page of the Project Properties dialog box to accomplish the same result. See "Setting compiler options" for more information.
java.lang
, or sun.io
, are rarely modified, so it is usually unnecessary to take the time to recheck them for consistency every time you compile. To prevent these libraries from being checked every time you compile, these packages are marked "stable." When all classes of a package have been successfully compiled, the package is considered "stable" and a flag is set in the dependency file. When only some classes of a package have been compiled or if an error occurred, then the package remains marked "unstable."
Stable packages won't be checked for consistency if you are compiling within the IDE and the Check Stable Packages option is off on the Build page of the Project Properties dialog box (Project|Project Properties) or if you specify the -nocheckstable option for the bmj command-line make (JBuilder Professional and Enterprise). As a result, stable packages are not checked for being up-to-date. However, if a package is included in your project, or if at least one source file in the package is included in your project, that package will be marked "unstable" and will be checked at every recompilation (that is, every time you do Project|Make Project).
In the IDE, if a package is marked stable but you are editing a file of that package outside of the IDE (using a different editor), it's best to include that package in the project so it is checked for recompiling. In the IDE, the compiler does not check packages marked stable to see if they are up-to-date, unless they are part of the project.
If this option is off or if the -nomakestable option is specified for the bmj compiler (JBuilder Professional and Enterprise), only the referenced classes of the package are made, and the package remains "unstable." This is useful when you are working with a library of classes for which you have no source code and some of the unused class files are not consistent.
To set compiler options,
.jpr
or .jpx
project node in the project pane.
Option | Description |
Include Debug Info | Includes symbolic debug information in the .class file when you compile, make, or rebuild a node. |
Show Warnings | Displays compiler warning messages. |
Show Deprecations | Displays all deprecated classes, methods, properties, events, and variables used in the API. When a warning is displayed that deprecated APIs were used, turn this option on to see specifically what is deprecated. |
Synchronize Output Dir | Deletes class files on the out path that you don't have source files for before compiling. The out path directory is specified in the Output Path field on the Paths page of the Project Properties. The location of source files are specified on the Source tab of the Project Properties Paths page. |
Check Stable Packages | Checks files in the packages that are marked "stable" to see whether they and their imported classes need to be recompiled. This option shortens the edit/recompile cycle by not re-checking stable packages.
If this option is off, a given branch of the checking process halts when it reaches a package marked stable; it does not look for unstable packages imported by the stable packages. With this option, you might need to specify a greater number of modules to compile. By default, the compiler checks packages marked stable as well as packages marked unstable to determine whether they and their imported classes need to be recompiled. |
Make Stable Packages | If this option is on, the compiler will compile or check all the classes of a package on the first build and mark the package "stable." If this option is off, only the referenced classes of this package will be made and the package will not be marked stable.
This option should be off when working with partial projects. This option is especially useful for working with a library of classes with no source available, when some of the class files are not consistent, but not used. |
Obfuscate | Obfuscation makes your programs less vulnerable to reverse engineering. After decompiling your obfuscated code, the generated source code contains altered symbol names for private symbols. |
Exclude Class | Excludes the selected .class file from a compile. |
Autosave All Files Before Compiling | Automatically saves all files in the project. |
Generate Source to Output Path | Causes source code generated from an RMI or IDL file during a make to be saved
in the out path. The out path is specified in the Output Path field of the Project Properties Paths page and defaults to the jbproject/project_directory_name/classes directory in the user's home directory.
|
You cannot set compile options per file; however, a file can be used by two projects, both of which have different settings for compiling. Applying options on classes or packages individually is not supported, because there is no separate compilation of headers and modules in Java. If some import information is missing (such as a class file), the imported class is compiled at the same time as the importing class, using the same project-wide options.
When you compile, make, or rebuild a node, symbolic debug information will be included in the .class file.
To set the output path,
These are features of JBuilder Professional and Enterprise.
bmj
or bcj
commands. To see the syntax and list of options, type bmj
or bcj
at the command line. You can also build a project from the JBuilder command line.
You might need to set the CLASSPATH
environment variable for the command line, so that the required classes are found.
This is a feature of JBuilder Professional and Enterprise.
bmj looks for dependency files on the Class Path, and does dependencies checking. If you specify a set of sources, some or all of those sources might not be recompiled. For example, the class files might be determined to be up to date if they have been saved but not edited since the last compile. You can force recompilation using the -rebuild option.
To check a set (or "graph") of interdependent modules, it is sufficient to call bmj on the root source (or multiple root sources if one is not under the other). You can specify this argument using source names, package names, class names, or a combination.
"The bmj command-line make"
"Setting the CLASSPATH
environment variable for command-line tools"
This is a feature of JBuilder Professional and Enterprise.
bcj does not do dependencies checking, and does not use or generate a dependency file. bcj only compiles the items you specify.
"The bcj command-line compiler"
"Setting the CLASSPATH
environment variable for command-line tools"
This is an option in JBuilder Professional and Enterprise.
jbuilder/bin
directory:
jbuilder -build <ProjectName.jpr>
For example, to build test.test3.jpr
which is located in the jbproject/project1
directory, enter the following at the command line from the jbuilder/bin
directory:
jbuilder -build jbproject/project1/test.test3.jpr
The default setting at the command line is to check consistency for referenced classes, regardless of whether their packages are marked "stable" or "unstable." The option -nocheckstable is not specified by default on the command line.