Problem of "can't find class file".

Saturday, August 14, 2010

Many time we have successfully added the class to a JAR, but when the web page tries to load the applet, the browser gives us an error "can't find class file". When unzipping the JAR, my added class is present.


Do not forget to add the "ARCHIVE" option to the APPLET tag like this

<applet code=my.class archive=archive.jar width=10 height=10>
</applet>

If "archive" is missing the browser will not know that your class is in a jar file...

Read more...

Applets have limited possibility to do many things

We know that applets have limited possibility to do many things. It is about network connections, file reading/writhing and more. Can applet read all system properties and if not how many of them arerestricted?

Now I shall say,  Applets can read quite many of system properties by using:

String ss = System.getProperty(String key):
java.version
java.vendor
java.vendor.url
java.class.version
os.name
os.arch
os.version
file.separator
path.separator
line.separator
Applets are prevented from reading these system properties:
java.home
java.class.path
user.name
user.home
user.dir




Read more...

How can my applet require some optional packages (specific vendor and versions)?

Since version 1.3 Java introduced support for an expanded set of Jar-file manifest attributes.

The following portion of a sample manifest file illustrates the attributes that are available for use by optional packages.

Extension-Name: javax.help
Specification-Vendor: Sun Microsystems, Inc
Specification-Version: 1.0
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Version: 1.0

Note that all of the above manifest attributes should be included in an optional package's manifest. If the plug-in looks for but doesn't find one of these attributes in an optional package's manifest, it will assume that the optional package is not suitable for the applet.

Note:  Optional packages are the new name for what used to be known as standard extensions. The "extension mechanism" is that functionality of the Java 2 SDK and Java 2 Runtime Environment that supports the use of optional packages. Optional packages are packages of Java classes (and any associated native code) that application developers can use to extend the functionality of the core platform. The extension mechanism allows the Java virtual machine (VM) to use the classes of the optional extension in much the same way as the VM uses classes in the Java 2 Platform. The extension mechanism also provides a way for needed optional packages to be retrieved from specified URLs when they are not already installed in the Java 2 SDK or Runtime Environment.

From SUN's description of the Java Extension Mechanism

Good to know: Invoking modal popup dialogs from an applet's stop or destroy methods is not recommended if you use Java 1.4.1 and below. Using modal popup dialogs inside these methods could result in problematic behavior, including NullPointerException, the dialog box not being displayed, the dialog box remaining alive even after the applet was destroyed, or in the worst case, browser hang. This problem has been fixed in 1.4.2.

Read more...

What are restrictions for an applet? What are applets prevented from doing?

In general, applets loaded over the net are prevented from reading and writing files on the client file system, and from making network connections except to the originating host.
In addition, applets loaded over the net are prevented from starting other programs on the client. Applets loaded over the net are also not allowed to load libraries, or to define native method calls. If an applet could define native method calls, which would give the applet direct access to the underlying computer.

Read more...