I've seen many tutorials, but none of them have worked in my case, I think it is because I'm using a .jar instead of an .class and in that .jar, I have more than just one Java class. Anyone knows how to solve this?
3 Answers
Ignore the DWR answers, they misunderstood your architecture. Applet code runs on client, not server.
What error message do you get?
Is the method you are trying to call public?
The way you are calling the Java method, the method has to be in the applet class. Is it?
It seems like your applet tag is missing the code attribute. It's required. Quoting an example from Oracle:
<applet codebase="http://java.sun.com/applets/NervousText/1.1"
code="NervousText.class" width=400 height=75>
<param name="text" value="Welcome to HotJava!">
<hr>
If you were using a Java-enabled browser such as HotJava,
you would see dancing text instead of this paragraph.
<hr>
</applet>
The code attribute must reference an applet class (a class that extends java.awt.Applet or javax.swing.JApplet) that can be found in one of the jars you've listed in the archive attribute. This has to be the full name of the class, something like: my.package.MyApplet (the .class at the end is optional).
2 Comments
Are you trying to call server side java from client side javascript? You would need to wire up a DWR call.