bcj command-line compiler

This is a feature of JBuilder Professional and Enterprise.

Syntax

bcj [ options ] {file.java}

Description

Borland Compiler for Java (bcj) compiles Java source code into Java bytecodes from the command line. bcj 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.

bcj compiles the selected .java file and any files specified on the command line. bcj compiles the specified .java file, whether or not its .class file is outdated. (An outdated .class file is one that was not generated by compiling the current version of its .java source file.) Imported .java files that already have .class files will not be recompiled, even if their .class files are outdated; after using the bcj command, some imported classes might still have outdated .class files.

bcj does not check dependencies between files.

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

You might need to use the -classpath option or set the CLASSPATH environment variable for the command line, so the required classes are found.

See also:
"Smart Dependencies Checking"
"Compiling from the command line"
"Setting the CLASSPATH environment variable for command-line tools" in "Using the command-line tools"
"Setting the classpath" in the Java Tools documentation
"bmj command-line make"

Options

Note: Directories listed in paths are separated by colons on the UNIX platform and by semicolons on the Windows platform. The following examples represent the UNIX platform.

-classpath path
The path used to find classes and dependency files. Overrides the default or the CLASSPATH environment variable. You should always include the outpath at the beginning of the path. The classpath is also used to search for sources if no sourcepath is specified. For example:
bcj -classpath jbproject/testing/classes/test3:
jbproject/project1/classes tester.java  

-d directory
The root directory of the class (destination) file hierarchy. Also referred to as the "outpath".

For example, the following statement:


bcj -d jbproject/project1/classes tester.java 
causes the class files for the classes defined in the tester.java source file to be saved in the directory jbproject/project1/classes/test/test3, assuming that tester.java contains the following package statement: package test.test3;

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 matches the package structure in the source files and starts from the root directory of the source.

-encoding name
You can specify a file-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 "Internationalizing programs with JBuilder" chapter of Building Applications with JBuilder.

For example, the following statement:

bcj -encoding EUC_JP tester.java
compiles tester.java. All source files are interpreted as being encoded in the EUC_JP character set, which is the character set typically used for Japanese UNIX environments. You can specify any encoding that is supported by the Java 2 platform. A list of the valid encodings is available at http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html#intl.

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

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

-sourcepath path
The path used to find sources. If no source path is specified, 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 compile tester.java, which contains the package statement package test.test3; and is located in jbproject/project1/src/test/test3, you must set the source path to jbproject/project1/src and not to jbproject/project1/src/test/test3.

You can then type the following:

bcj -sourcepath jbproject/project1/src
jbproject/project1/src/test/test3/tester.java 
-d jbproject/project1/classes

-verbose
This option gives more information about compiling, such as which class files are loaded from where in the classpath, including:

Cross-compilation options

bcj supports cross-compilation, where classes are compiled against a bootstrap and extension classes of a different Java platform. Use -bootclasspath and -extdirs when cross-compiling.

-target version
Generates the class files to work on a specific VM version. The default is to generate class files that are compatible with versions 1.1 and VMs in the Java 2 SDK. The javac in Java 2 SDK supports:

-bootclasspath bootclasspath
Cross-compiles against the specified boot classes. Entries can be directories, JAR archives, or ZIP archives.

-extdirs directories
Cross-compiles against the specified extension directories. Each JAR file in the specified directories is searched for class files.

VM options

-Joption
Passes options to the java launcher called by bcj. For example, -J-Xms48m sets the startup memory to 48 megabytes. It is a common convention for -J to pass options to the underlying VM executing applications written in Java.

Note that CLASSPATH, -classpath, -bootclasspath, and -extdirs do not specify the classes used to run bcj. If you do need to do this, use the -J option to pass through options to the bcj launcher.