Spec-Zone .ru
спецификации, руководства, описания, API
|
java.lang.InstantiationException: either code or object should be specified, but not both
SymptomsWhen running an applet in a browser using the Sun JavaTM Runtime Environment (JRETM) implementation, a
java.lang.InstantiationException
is thrown. The same applet runs without any errors with the Microsoft Virtual Machine (VM).Cause
There are two possible causes.
- Both
code
andobject
attributes are specified in the<APPLET>
tag:
<APPLET code=MyApplet object=MyApplet.ser width=100 height=100>
</APPLET>
The Sun JRE can access thecode
or theobject
attribute, and not both.
- A
code
attribute is specified in the<APPLET>
tag, and anobject
attribute is specified in a<PARAM>
tag as shown in the following code:
<APPLET code=MyApplet width=100 height=100>
<PARAM name="object" value="someValue">
</APPLET>
public class MyApplet extends java.applet.Applet
{
public void init()
{
String value = getParameter("object");
}
....
}
The Sun JRE does not supportobject
as a parameter name.Resolution
In the first cause eliminate the
code
attribute in the<APPLET>
tag as shown in the following code:
<APPLET object=MyApplet.ser width=100 height=100>
</APPLET>
In the second cause change the parameter name to a different name as shown in the following code:
<APPLET code=MyApplet width=100 height=100>
<PARAM name="property1" value="someValue">
</APPLET>
public class MyApplet extends java.applet.Applet
{
public void init()
{
String value = getParameter("property1");
}
....
}
Related Information
None.
Java Technology |
Copyright © 1993, 2010, Oracle and/or its affiliates. All rights reserved. |