bcj command-line compiler

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 of its imported files that do not have .class files. 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.) bcj also compiles any directly imported .java files that do not have .class files. 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 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: bmj command-line compiler

Options

-classpath path
The path used to find classes. Overrides the default or the CLASSPATH environment variable. Directories are separated by semicolons. It is often useful for the directory containing the source files to be on the class path. You should always include the system classes at the end of the path.

For example:

bcj -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:

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

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

bcj -encoding SJIS tester.java
compiles tester.java and any directly imported .java files that do not have .class files. 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.

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

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