Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

class is not public or has no public constructor

9 views
Skip to first unread message

MAC0n

unread,
Nov 23, 2000, 3:00:00 AM11/23/00
to
load: test.class is not public or has no public constructor.
java.lang.IllegalAccessException: shares
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:484)


any suggestions??

Cheers
:-)

Niek van Suchtelen

unread,
Nov 23, 2000, 8:18:27 PM11/23/00
to
As the error message tells you, your class isn't a public class. How do
you fix that? Yes... simply by adding the 'public' keyword right before
'class', like this:

public class MyClass {
...
}

Also, you have to make sure that, if your class has a contructor, the
contructor is public too:

public class MyClass {
public MyClass() {
...
}
}

You should be able to find more about this in any Java book though.. By
the way: your class name (test) doesn't follow Sun's name
specifications.. class names always start with a capital letter, like
this: Test.class (but don't just rename the file! also the source).

Niek

David 'Superkind' Roden

unread,
Nov 24, 2000, 3:00:00 AM11/24/00
to

> load: test.class is not public or has no public constructor.
> [snip]
> any suggestions??

Well, that's of course hard to say without any source, but I think your class
is not public of has no public constructor.


So long,
David

--
---------. .---------------------------------
Superkind \ supe...@uni-neukoelln.de / http://xxxxxxxxx.xxx-xxxxxxxxx.xx
~--------------------------~

Patricia Shanahan

unread,
Nov 24, 2000, 3:00:00 AM11/24/00
to

and there is an attempt to create an instance of the class in a context
that needs it to be public. Either you intend to allow creation of
instances of the class from anywhere in the program, and need to add
"public" to the class and constructor declarations, or you are creating
an instance in the wrong place, and need to change that.

Patricia

MAC0n

unread,
Nov 24, 2000, 5:24:39 PM11/24/00
to
well- thank you all for your help but my class does have a public
constructor....
i've noticed that sometimes it works - sometimes it doesn't... especially
when i change the security settings.

Sometimes it launches two japplets when i run it in appletviewer.

cheers

PS. i've also tried to view this Japplet on another pc and it complaints
that it can't find japplet.class -
Java plugin and jdk is installed
:)


0 new messages