![]() | Documentation Contents |
java.lang.ClassNotFoundExceptionThrown by theClassLoaderon thecom.ms.securityPackage
SymptomsWhen running an applet in a browser using the Sun JavaTM Runtime Environment (JRETM), a
java.lang.ClassNotFoundExceptionis thrown by theClassLoaderon thecom.ms.securitypackage. The same applet runs without any error under the Microsoft Virtual Machine (VM).Cause
The Microsoft VM provides the proprietary
com.ms.securitypackage for applets and applications to access the security policy at runtime. Because this package is not available in the Sun JRE, ajava.lang.ClassNotFoundExceptionis thrown when the applet runs in a browser.Resolution
Migrate the applet source from the
com.ms.securitypackage to thejava.securitypackage by using similar classes.
For example, the following applet usescom.ms.security.PolicyEngineto assert the network I/O permission before connecting to a URL:
public class AssertPermissionApplet extends java.applet.Applet
{
public void init()
{
try
{
// Assert permission on network I/O
com.ms.security.PolicyEngine.assertPermission
(com.ms.security.PermissionID.NETIO);
java.net.URL url = new java.net.URL("http://randomhost/randomfile");
.....
} catch (java.net.MalformedURLException mue) {
}
catch (java.io.IOException ioe) {
}
} // init
}In the Java technology,
java.security.AccessControllerprovides similar functionality for permission assertion. The following source code displays the functionality after migration:
public class AssertPermissionApplet extends java.applet.Applet
{
public void init()
{
try
{
// Assert permission on network I/O
java.security.AccessController.checkPermission(new java.net.SocketPermission("randomhost:80", "connect,accept"));
java.net.URL url = new java.net.URL("http://randomhost/randomfile");
.....
} catch (java.net.MalformedURLException mue) {
}
catch (java.io.IOException ioe) {
}
} // init
}See the JavaTM SE technology API documentation for more details about security.
Related Information
See Security.
Copyright © 1993, 2010, Oracle and/or its affiliates. All rights reserved. Please send comments using this Feedback page. |
Java Technology |