Documentation Contents |
java.lang.ClassNotFoundException
Thrown by theClassLoader
on thecom.ms.security
Package
SymptomsWhen running an applet in a browser using the Sun JavaTM Runtime Environment (JRETM), a
java.lang.ClassNotFoundException
is thrown by theClassLoader
on thecom.ms.security
package. The same applet runs without any error under the Microsoft Virtual Machine (VM).Cause
The Microsoft VM provides the proprietary
com.ms.security
package for applets and applications to access the security policy at runtime. Because this package is not available in the Sun JRE, ajava.lang.ClassNotFoundException
is thrown when the applet runs in a browser.Resolution
Migrate the applet source from the
com.ms.security
package to thejava.security
package by using similar classes.
For example, the following applet usescom.ms.security.PolicyEngine
to 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.AccessController
provides 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 |