Jvc Reference Previous
Previous
About Tools
About Tools
Next
Next

Introduction to Jvc

Description of Jvc Syntax , File Name Syntax , Using Jvc.exe , Order of Jvc Options , Jvc Command Files , CLASSPATH Environment Variable , Reference to Jvc Command-Line Options

Jvc.exe (jvc) is the Microsoft compiler for Java. The compiler produces interpreted (.class) files that will run on any Virtual Machine. For an alphabetic reference to the jvc options, see Reference to Jvc Command-Line Options.


Description of Jvc Syntax

The Jvc.exe (jvc) command line uses the following syntax:

JVC [options] <filename>

The following table describes input to the jvc command.
Entry Meaning
option One or more jvc options. See Reference to Command-Line Options for more information. Note that all options apply to all specified source files.
filename Name of one or more source files.

You can specify any number of options and file names, as long as the number of characters on the command line does not exceed 1024 or the limit dictated by the operating system.

Note There is no guarantee that future releases of Microsoft® Windows NT® (version 4.0 and later) and Microsoft Windows 95® will have the same input limit of 1024 characters for the command line.

Any options that you want to pass to jvc must be supplied before the name of the .class file or they will be interpreted as command-line arguments to the .class file.


File Name Syntax

The jvc recognizes the following file name syntax:

Note If a file does not have an extension, jvc assumes the extension of .java.


Using Jvc.exe

You can use Jvc.exe (jvc) to compile specified .java source files into interpreted .class files. To compile without producing the .class files, use the /nowrite option. You can specify jvc options on the command line. If you are compiling your Java project from the command line, place the options you want to supply to jvc before the name of your .class file on the command line.


Order of Jvc Options

Command-line options can appear anywhere on the Jvc.exe (jvc) command line. Jvc reads the command line from left to right processing command files in the order it encounters them. Each option applies to all files on the command line. If jvc encounters conflicting options, it uses the rightmost option.


Jvc Command Files

A command file, also referred to as a response file, is a text file that contains information you would otherwise type on the command line. Jvc accepts a command file as an argument on the command line. Unlike the command line, a command file allows you to use multiple file names.

The criteria listed below should be followed when using command files:

A command file is specified by an "at" sign (@) followed by a file name; the file name can specify an absolute or relative path.


CLASSPATH Environment Variable

Use the CLASSPATH environment variable to specify additional class path information when compiling from the command line. The CLASSPATH environment variable has the following syntax:

SET CLASSPATH = <path>

An understanding of where the Virtual Machine (VM) and the command line get class path information will explain why your Java program may behave differently depending on where it executes. When the Virtual Machine (VM) installs, it enters the value C:\Windows\Java\Classes\Classes.zip;.; into the registry key HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM\Classpath. When a Java program runs, the VM first looks for the CLASSPATH value in the registry. If the application executes from the command line, the VM also uses the CLASSPATH environment variable if one has been set.

What this means is if you are executing from the:


Reference to Jvc Command-Line Options

This topic is an alphabetic reference to all the jvc command-line options. If a command-line option can take one or more arguments, its syntax is shown before its description. Click any option in the following table for information on the option.
Jvc options set from the command line
/cp /g:l /O:J
/cp:o /g:t /verbose
/cp:p /nowrite /w
/d /O /?
/g /O:I

/cp

/cp classpath

Use the /cp option to set the CLASSPATH environment variable for the current compilation. Using this option specifies the path where the jvc or jview command-line tools can find system and user-defined classes. The Java interpreter uses a platform-dependent default location and the CLASSPATH environment variable to find system classes. (See CLASSPATH Environment Variable for more information.) The directories in the class path are separated by semicolons on a Microsoft Windows system; by colons on UNIX.

Example:

For example, on Windows NT, the class path might be:

JVC /cp x:.;x:\java\classes

In this example, jvc searches in and beneath the directories on the path for system and user-defined classes.


/cp:o

This option prints the class path to standard output. This option is especially useful for troubleshooting errors, like "class not found," when compiling from the command line.

Example:

The following example prints the class path to the screen.

JVC /cp:o

/cp:p

/cp:p path

This option is inserted before the path entered to the class path and inserts a semicolon between them. When multiple /cp:p switches are entered, the paths are concatenated.

Note The value for the class path may come from the CLASSPATH environment variable or from the /cp option. When multiple /cp:p switches are entered, the paths are concatenated.

Example:

The following command concatenates the directories, myproj1 and myproj2, and is inserted before the resulting path to the existing class path:

JVC /cp:p myproj1 /cp:p myproj2

/d

/d directory filename

When compiling .java files, use the /d option to specify an output directory other than the current directory for the .class files. If the directory does not exist, jvc will create it.

Example:

The following command compiles the myClass.java file into a myClass.class file and writes this file into the class directory.

JVC /d c:\classdir myClass.java

/g

/g[-] filename

The /g option generates all debugging information. No debugging options are set by default. The effect of using the /g switch is the same as using the following options together:
Option Action
/g:l Generate line number information
/g:t Generate debug tables

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following command creates a .class file called myClass.class that contains debugging information:

JVC /g myClass.java

The following command instructs jvc to exclude debugging information from the myClass.class file:

JVC /g- myClass.java

/g:l

/g:l[-] filename

This option generates line numbers that are used when debugging an program. No debugging options are set by default.

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following command instructs jvc to generate line-number information for the resulting myClass.class file:

JVC /g:l myClass.java

The following command instructs jvc to turn off line-number generation:

JVC /g:l- myClass.java

/g:t

/g:t[-] filename

This option generates debug tables that are used when debugging an program. No debugging options are set by default.

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following command instructs jvc to generate debug-table information for the resulting myClass.class file:

JVC /g:t myClass.java

The following command instructs jvc to turn off debug-table generation:

JVC /g:t- myClass.java

/nowrite

/nowrite filename

The /nowrite switch tells jvc to compile a .java file and to suppress the writing of a .class file.

Example:

In the following example, the myClass.java file is compiled, errors and warnings are reported, but no myClass.class file is produced:

JVC /nowrite myClass.java

/O

/O filename

The /O option combines optimizing options to produce the fastest possible program. The effect of using this option is the same as using the following options together:
Option Action
/O:I Optimize by inlining methods when appropriate
/O:J Optimize bytecode jumps. Default optimization setting.

Note To disable any optimization option, use a dash (–) after the switch on the command line.

Examples:

The following command fully optimizes the code for myClass.class file that is produced:

JVC /O myClass.java

The following command turns off all code optimization:

JVC /O- myClass.java

/O:I

/O:I filename

The /O:I option tells the compiler it can inline methods to produce more efficient code. Code that is inlined does not have the overhead associated with a method call. Since there is no mechanism in the Java language to request inlining of methods, use this option when you want the compiler to inline your code.

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following example evaluates the source code in the myClass.java file and inlines methods where possible. The resulting myClass.class file contains the optimized code.

JVC /O:I myClass.java

The following command turns off all inline-code optimization:

JVC /O:I- myClass.java

/O:J

/O:J filename

The /O:J option causes jvc to optimize the bytecode jumps in the compiled .class file. This switch tells the compiler to generate code that jumps to another jump. This switch is the compiler's default optimization setting.

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following example evaluates the source code in the myClass.java file and optimizes the bytecode jumps to produce more efficient code. The resulting myClass.class file contains the optimized code.

JVC /O:J myClass.java

The following command turns off bytecode jump optimization:

JVC /O:J- myClass.java

/verbose

/verbose filename

This option instructs jvc to display all messages while compiling a file or project. These messages give useful information about the progress of the compilation.


/w

/w0
/w1
/w2
/w3
/w4

These options control the number of warning messages produced by the compiler. They affect only source files named on the command line.

Compiler warning message numbers begin with J5. The documentation describes the warnings, indicates each warning's level, and indicates potential problems (rather than actual coding errors) with statements that might not compile as you intend.

The meaning of the options is as follows:
Option Description
/w0 Turns off all warning messages.
/w1 Displays severe warning messages.
/w2 Displays a less-severe level of warning message than /w1. This is the default.
/w3 Displays a less-severe level of warning message than /w2, including use of methods with no declared return type, failure to put return statements in methods with nonvoid return types, and data conversions that would cause loss of data or precision.
/w4 Displays the least severe level of warning messages.


/x

/x[-] filename

This compiler supports the Java language specification. In addition, the compiler might offer a number of features beyond those required by the Java language specification. These features are available by default, and are not available when the /x option is specified.

Use /x if you plan to port your program to other environments. The /x option tells the compiler to treat extended keywords as simple identifiers and to disable the other Microsoft extensions.

Note To disable this option, use a dash (–) after the switch on the command line.

Examples:

The following command ignores any extensions used in the myClass.class file.

JVC /x myClass.java

The following command restores the default settings and recognizes the language extensions.

JVC /x- myClass.java

/?

/?

This option displays a listing of compiler options to standard output.



Top© 1996 Microsoft Corporation. All rights reserved.