Skip to main content
gamedev.net
🔒 Locked

[web] Java Applet Error "Not Public?"

Started by GTspeed 1 reply 550+ views
Original Post
GTspeed
GTspeed
I'm currently trying to develop a browser game using Java. I've just started using Java and tried to create a simple applet to run on a web page. Yet, it just doesn't seem to work. The Java console on Firefox gives me this error message: load: HelloWorldApp.class is not public or has no public constructor. java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access a member of class HelloWorldApp with modifiers "" at sun.reflect.Reflection.ensureMemberAccess(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) This is my source code: import java.awt.*; import java.applet.*; public class HelloWorldApp extends Applet { public static void main (String [] args) { System.out.println("Hello World!"); } } It compiles fine but does not work on the webpage. Any help would be extremely appreciated.
GTspeed
GTspeed
Quote:
Original post by OrangyTang
Applets don't use a main() method, only java applications do. Look up an applet tutorial (or even the Applet class in the javadocs) and it'll show you how to provide init, run and paint methods for applets.


Wow that seems really easy now that I've done it. Thanks for the help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.