Applet doesnt load onto browser; but runs on appleviewer.

Applet runs fine with appletviewer but doesnt run on browser.

I am getting a stack trace complete with exception; something like :-

load:myApplet is not public or has no public constructor

java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access a member of class myApplet with modifiers ""

at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)

at java.lang.Class.newInstance0(Class.java:344)

at java.lang.Class.newInstance(Class.java:303)

at sun.applet.AppletPanel.createApplet(AppletPanel.java:721)

at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1760)

at sun.applet.AppletPanel.runLoader(AppletPanel.java:650)

at sun.applet.AppletPanel.run(AppletPanel.java:324)

at java.lang.Thread.run(Thread.java:595)

I have double checked there is no such method which calls a method that doesnt have access to it.

Please guide.

Thanks.

[959 byte] By [kaprasannaa] at [2007-11-27 2:25:55]
# 1
can you show the first lines of your applet (class declaration + constructor)
calvino_inda at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 2
I shall try and put my code here soon (after making some changes for making it general) but for now, if the doubt is about the public constructor,I have duely added it, though I dont need it.
kaprasannaa at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 3

> can you show the first lines of your applet (class

> declaration + constructor)

I think, the solution to this problem is in this line :

java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access a member of class myApplet with modifiers ""

-- what does the last part of line :-class myApplet with modifiers "" signify?

Getting any clue?

Plz guide.

Thanks

kaprasannaa at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 4

> I shall try and put my code here soon (after making

> some changes for making it general) but for now, if

> the doubt is about the public constructor,I have

> duely added it, though I dont need it.

--Here is the code..

import java.net.*;

import java.io.*;

import java.applet.*;

public class myApplet extends Applet

{

//Temperory method

void call()

{

System.out.println("Method called..../////");

}

public myApplet()

{

System.out.println("Constructor called.....");

}

public void start()

{

call();

}

}

kaprasannaa at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 5

> can you show the first lines of your applet (class

> declaration + constructor)

I am using this command for running using appletviewer as an workaround for security related issues :

appletviewer -J-Djava.security.policy=polfile myApplet.html.

In the html file, I have added jar file as a value to attribute 'archive'.

Plz help...

kaprasannaa at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 6
i only used applet oncewhen i did, i didn't use any jar but included the .class file of the applet in the html file
calvino_inda at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...
# 7
Are you very sure that the code you posted is the same that you're running, in case you tried to fix the "public" problems previously? Your browser could be caching an old version.
CeciNEstPasUnProgrammeura at 2007-7-12 2:34:51 > top of Java-index,Java Essentials,Java Programming...