Working with MS VM
 In this topic

*Description of Jview Syntax

*Using Jview.exe

*Reference to Jview Command-Line Options

 

Tools    PreviousToolsNext
Jview Reference     Previous Tools Next

 


Introduction to Jview

Jview.exe (jview) is a tool used to execute Java applets and applications from the command line. Jview provides an environment that your application can run in. It supports both debug and retail versions of your application.

Jview supports both applications and applets. If your Java project has a main method, jview will execute it. Jview executes applets, when used with the /a switch, by sending the applet to the Microsoft AppletViewer. For more information on the /a option, as well as a reference to other jview options, see Reference to Jview Command-Line Options.

Description of Jview Syntax

The Jview.exe (jview) command line uses the following syntax.

jview [options] <classname> [arguments]

The following table describes possible command-line input to the jview tool.
Entry Meaning
options One or more jview options. For more information, see Reference to Jview Command-Line Options.
classname The name of the .class file to execute. Do not include the .class extension to this filename. For example, use HelloWorldApplet rather than HelloWorldApplet.class.
arguments Command-line arguments to be passed to the .class file supplied in classname parameter.

Note Any options you want to supply to jview must be specified before the name of the .class file or they will be interpreted as command-line arguments to the .class file.

Using Jview.exe

You can specify Jview.exe (jview) options on the command line. If you are executing your Java applet or application from the command line, enter the options you want to supply to jview before the name of your .class file on the command line.

Reference to Jview Command-Line Options

This section is an alphabetic reference to all the jview command-line options. If a command-line option can take one or more arguments, its syntax is shown before its description.

To learn more about a particular jview option, choose the option from the following table.
/a /cp /cp:a /cp:p /v /p /d:

/a

/a

Use the /a option to invoke the Microsoft AppletViewer in the jview and wjview utilities. Applets run with the applet viewer behave the same as when run by a browser host application, including loading, sound, and security. The applet viewer accepts applet parameters and class names, in addition to URLs and HTML files.

When the /a option is used, any remaining command line tokens become parameters for the applet viewer.

Example:

You can load an applet either by using an HTML file to specify parameters, or by loading parameters directly from the command line. The following example shows how to load an applet from an HTML source file with the applet tag.

<applet code=MyApplet.class width=100 height=200>
               <param name=SomeName value=SomeValue></applet>

The same applet can run in the applet viewer with the following command line information.

jview /a width=100 height=200 SomeName=SomeValue MyApplet

The following example shows how to run more than one applet at a time, with the docbase as the current directory.

jview /a width=200 height=400 MyApplet height=300 MySecondApplet

This displays the first applet in a 200 x 400 frame, and the second applet in a 200 x 300 frame. If no height and width are specified on the command line, the applet's default size is one-third of the size of the screen.

Any parameter, including HTML files, will be loaded from the classpath. An example of this is as follows:

jview /a /cp \src\bvt MyApplet.html

/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. For more information, see CLASSPATH Environment Variable. The directories in the classpath are separated by semicolons on a Microsoft® Windows® system; on UNIX, by colons.

Example:

For example, on Microsoft® Windows®NT, the classpath might be as follows:

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

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

/cp:a

/cp:a path

Appends the path entered to the end of the CLASSPATH environment variable, and inserts a semicolon between them.

For a full description of the CLASSPATH environment variable, see CLASSPATH Environment Variable.

Note The value for the classpath can come from the CLASSPATH environment variable or from the /cp option. When multiple /cp:a switches are entered, the paths are concatenated.

Example:

The following command concatenates the directories, myproj1 and myproj2, and appends the resulting path to the end of the existing classpath.

jview /cp:a myproj1 /cp:a myproj2

/cp:p

/cp:p path

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

Note The value for the classpath can come from the CLASSPATH environment variable or from the /cp option. For more information, see CLASSPATH Environment Variable.

Example:

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

jview /cp:p myproj1/cp:p myproj2

/v

/v

Use the /v option to cause jview to verify all invoked methods. Without this option, only methods from untrusted loaders are verified. Verification is a process applied to the bytecode loaded from the class files to ensure that it does not pose a security threat. For remotely loaded class files, the Microsoft Win32 VM for Java (Microsoft VM) allows only a subset of the total functionality possible with the bytecode language. Verification enforces this so that if your class files attempt to do anything illegal, the class file is rejected.

For performance reasons, local system classes are not normally verified. The /v option forces the verifier to process these. You can use this to ensure that a set of class files will pass the verifier.

/p

/p

Use the /p option to force jview to pause before exiting if an error occurs. You can use this to determine the user interface state just prior to the error when debugging an application.

/d:

/d:property=string value

Use the /d: option to set a system property. System properties can be read using the java.lang.System.getProperty or java.lang.System.getProperties methods. See these methods for descriptions of system properties. As an example, you can use the following command line to set the user.dir property to some arbitrary value.


jview /d:user.dir=c:\java\test  myapp 

You can also set user-defined properties. For example, you can set a property called "myprop" with the following command-line.


jview /d:myprop=12   myapp 

Top © 1998 Microsoft Corporation. All rights reserved. Terms of use.