Lew wrote:
>>> class Just
>>> {
..
>Doesn't the class need to be public?
I watched the discussion about public (or not) classes
and the JLS with interest. AFAIU, normal classes with
main() do not need to be public, OTOH *Applet* classes
must be public..
<sscce>
class DefaultAccessApplet extends
java.applet.Applet {
public void init() {
add( new
java.awt.Label("Default Access") );
}
}
</sscce>
[console]
load: DefaultAccessApplet.class is not public or has no public constructor.
java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access
a
member of class DefaultAccessApplet with modifiers ""
[/console]
I could not say whether that was according to the JLS,
or simply an 'implementation detail' but it explains why
a lot of people are used to seeing 'main()' classes as
needing to be public, as so many (far too many) simple
code examples are written as Applets.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200704/1