bmj command-line compiler

Sytax

bmj [options] rootClasses

Description

Borland Maker for Java (bmj) compiles Java source code into Java bytecodes from the command line and checks for dependencies to determine which files actually need to be recompiled. bmj produces the Java program in the form of .class files containing bytecodes that are the machine code for the Java virtual machine. Compiling a source file produces a separate .class file for each class declaration or interface declaration. 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.

bmj looks for dependency files on the classpath. 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 classes, it is sufficient to call bmj on the root class (or multiple root classes, if one is not under the other). You can specify root classes using class names, package names, names of sources that declare classes, or a combination.

To see the syntax and list of options at the command line, enter the bmj command with no arguments.

You might need to run setvars.bat to set the environment variables for the command line, so the required classes are found.

See also:
Building Applications with JBuilder, "Compiling Java programs:" Smart Dependencies Checking
Building Applications with JBuilder, "Compiling Java programs:" Compiling from the command line
Building Applications with JBuilder, "Command line tools:" Setting environment variables for command-line tools
Building Applications with JBuilder: bcj command-line compiler

Options

-classpath path
The path used to find classes and dependency files. Overrides the default or the CLASSPATH environment variable. Directories are separated by semi-colons. You should always include the system classes at the end of the path. The classpath is also used to search for sources if no sourcepath is specified and if no SOURCEPATH environment variable is set.

For example:

bmj -classpath c:\testclasses\test3;c:\mydir;c:\jbuilder\myclasses tester.java
If no CLASSPATH is defined, the default classpath is:
%JAVAHOME%\classes;%JAVAHOME%\lib\classes.zip

If JAVAHOME is not defined, the default classpath is:
\java\classes;\java\lib\classes.zip

-d dir
The root directory of the class (destination) file hierarchy.

For example, the following statement:

bmj -d c:\jbuilder\myclasses tester.java
causes the class files for the classes defined in the tester.java source file to be saved in the directory c:\jbuilder\myclasses\test\test3 directory, assuming that tester .java contains the following package statement: test.test3

The updated dependency file test.test3.dependency will also be saved in that directory.

Files are read from the class path and written to the destination directory. The destination directory can be part of the class path. The default destination for class files matches the package structure in the source files and starts from the root directory of the source. The default destination for dependency files matches the package structure and starts in the current directory.

-deprecation
Displays all deprecated classes, methods, properties, events, and variables used in the API.

If a warning is displayed when compiling, indicating that some deprecated APIs were used, you can turn this option on to see all deprecated APIs.

-encoding name
You can specify a native-encoding name (or codepage name) to control how the compiler interprets characters beyond the ASCII character set. The default is to use the default native-encoding converter for the platform. For more information, see the topic called Specifying a native encoding for the compiler in the "Internationalization with JBuilder" chapter.

For example, the following statement:

bmj -encoding SJIS tester.java
does a Make and dependency checking starting with root classes declared in tester.java. Characters in all source files are interpreted as the PC and Windows character set for Japanese.

-g
Generates debugging information in the class file, such as line numbers and local variables.

-nocheckstable
Does not check 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 skipping re-checking stable packages.

With this option, 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. Therefore, with this option, you might need to specify a greater number of modules to compile. Suppose unstable package A uses stable package B, which uses unstable package C. If you want to skip rechecking the stable package B, then you need to specify compiling package C in addition to package A; otherwise, package C will not be checked (unless A depends directly on C).

By default, bmj checks packages marked "stable" as well as packages marked "unstable", to determine whether they and their imported classes need to be recompiled. For more information, see the topic called Selectively compiling stable packages in "Compiling Java programs."

-nocompile
Checks whether the classes are up-to-date, but doesn't compile any classes. Useful for quickly checking whether a class or package is up to date. Stops at the first file needing recompilation, and reports "Class <class> needs recompiling because <reason>."

-nomakestable
If this option is not specified, bmj will Make (compile or check) all the classes of a package on the first build and mark the package "stable". With this option, only the referenced classes of this package will be made, and the package will not be marked "stable".

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.

See also:
Building Applications with JBuilder, "Compiling Java programs:" The Make command
Building Applications with JBuilder, "Compiling Java programs:" Selectively compiling stable packages

-nowarn
Compiles without displaying warnings.

-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.

-quiet
Compiles without displaying any messages.

-rebuild
The Rebuild command compiles the specified root classes and their imported files, regardless of whether they have changed.

See also:
Building Applications with JBuilder, "Compiling Java programs:" The Rebuild command

-sourcepath path
The path used to find sources. Overrides the default SOURCEPATH for the command-line environment. To see the SOURCEPATH, use the DOS set command.

If no source path is specified and if no SOURCEPATH environment variable is set, the classpath is used to find the sources.

Similar to the classpath, the sourcepath must point to the root of the package directory tree, and not directly to the directory of the sources. For example, to make tester.java, which contains the package statement test.test3 and is located in d:\mydir\test\test3, you must set the source path to d:\mydir and not to d:\mydir\test\test3. From any current directory, you can then type the following:
bmj d:\mydir\test\test3\tester.java -d d:\myclasses

-verbose
This option gives more information about compiling, such as which class files and dependencies files are loaded from where in the classpath. The following information is displayed:

Specifiers for root classes

Root classes are specified in the following form:
{[-s] {source.java} | -p {package} | -c {class}}

-s sourcefilename
Indicates that the specified root classes are those defined in the given source files. This is the default interpretation.

For example, the following statement:

bmj -s borland\samples\tutorial\dataset\CalcField.java
is the same as
bmj borland\samples\tutorial\dataset\CalcField.java

If you list some packages with the -p option before listing sources, then you need to specify the -s option. If you list sources before packages and classes, the -s is assumed, and is not necessary.

-p packagename
The name of packages to compile.

For example, the following statement:

bmj -p borland.samples.tutorial.dataset
makes all classes of the borland.samples.tutorial.dataset package, and all imported classes.

-c classname
The names of the classes to Make.

For example, the following statement:

bmj -c borland.samples.tutorial.dataset.CalcField
makes the class CalcField of package borland.samples.tutorial.dataset and all imported classes.

As another example, the following statement:

bmj tester.java -p package1 package2 -s mydir\*.java
makes the source file tester.java, packages package1 and package2, and all the java files in the mydir\ directory.

Note that the first source name (tester.java) comes before the -p (package) option, so does not need to explicitly specify the -s option, because -s is assumed. If you want to specify another source file name after the -p option is specified, you have to explicitly specify the -s option.