Applet Viewer

How do you configure JCreator to run nn applet. Under tools there is a runtime configuration setup for applet viewer but I don't understand what exactly is needed in the various boxes, such as label. An applet is a program written in the Javatm programming language that can be included in an HTML page, much in the same way an image is included. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM).

Applet viewer is a command line program to run Java applets. It is included in the SDK. It helps you to test an applet before you run it in a browser.

Applet viewer is a command line program to run Java applets. It is included in the SDK. It helps you to test an applet before you run it in a browser.

Applet Viewer Online


Applet viewer is a command line program to runJava applets. It is included in the SDK. It helps you to test an applet beforeyou run it in a browser. Before going any further, lets see what an applet is?
An applet is a special type of application that's included as a partof an HTML page and can be stored in a web page and run within a web browser. The applet's codegets transferred to the system and then the Java Virtual Machine (JVM) of thebrowser executes that code and displays the output.. So for running theapplet, the browser should be Java enabled. To create an applet, we need to define a class that inherits theApplet.

We generally use web browsers to run applets. Its notalways mandatory to open a Web browser for running an applet. There is anotherway as well. The other way to run an applet is through Java applet viewer.This is a tool that acts as a test bed for Java applets. The working of Appletviewer is a bit different from a Web browser, though they are logically same.The Applet viewer runs on the HTML documentation, and uses embedded applet tags.The difference in using the applet viewer and the web browser to run the appletis that the applet viewer only deals with the applet code not the HTML cod i.e.it doesn't display HTML code. So we should test our program in applet viewer andweb browser to confirm its working.

The applet viewer command connects to the documents or resources designated byurls. Itdisplays each applet referenced by the documents in its own window.

The syntax for the applet viewer is:
appletviewer Options URL
Where the URL specifies the location of the appletprogram and the Options argument specifies how to run the Java applet.We can use only one option -debug that starts the applet viewer in the Javadebugger. Using this option we can debug an applet.

The following program shows how to build an applet andthe HTML file for it. Firstly create a class. Then start the applet using initmethod. After that enter a string as str ='This is my first applet'. Use paintmethod to give the dimensions of the applet.Beneath that is the HTML file which shows how to give the body for applet.

Here is the Java File:

Here is the HTML File:

<HTML>
<BODY>
<applet code='Myapplet',height='200' width='200'>
</applet>
</BODY>
</HTML>

After building the program, run the applet and theapplet viewer as shown below.

C:javac> javac Myapplet.java
C:javac>appletviewer Myapplet.html

When we run the applet viewer it will display thewindow as shown below.


Ads

Note:You use the appletviewer command to launch the AppletViewer and run applets outside of a web browser.Although available and supported in JDK 9, the Applet API is marked as deprecated in preparation for removal in a future release. Instead of applets, consider alternatives such as Java Web Start or self-contained applications.

Applet Viewer

Synopsis

options

Specifies the command-line options separated by spaces. See Options for appletviewer.

url

Applet Viewer Software

Specifies the location of the documents or resources to be displayed. You can specify multiple URLs separated by spaces.

Description

The appletviewer command connects to the documents or resources designated by url and displays each applet referenced by the documents in its own AppletViewer window. If the documents referred to by url don’t reference any applets with the OBJECT, EMBED, or APPLET tag, then the appletviewer command does nothing. The OBJECT, EMBED, and APPLETtags are described in AppletViewer Tags.

The appletviewer command requires encoded URLs according to the escaping mechanism defined in RFC2396. Only encoded URLs are supported. However, file names must be unencoded, as specified in RFC2396.

Note:

The appletviewer command is intended for development purposes only.

Options for appletviewer

-encoding encoding-name

Specifies the input HTML file encoding name.

-Jjavaoption

Passes the string javaoption as a single argument to the Java interpreter, which runs the AppletViewer. The argument shouldn’t contain spaces. Multiple argument words must all begin with the prefix -J. This is useful for adjusting the compiler's execution environment or memory usage. Seejava command documentation for more information about JVM options.