Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Struts and the fly likes Problem when calling applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem when calling applet" Watch "Problem when calling applet" New topic

Problem when calling applet

Dani Acedos

Joined: Apr 18, 2011
Posts: 4

I am facing problems when I try to execute an applet from a Struts application, I have seen some threads but none posted the last code to resolve it.

I want to call an applet from one of my jsp's under web/jsp

I created the folder applets under web as well and I placed the JavaApplication15.jar which is only a Main.class (no packages, no libs... just a System.out.println to know if it is being called)

it works if I call the applet from a static html file with

I have tried to include this applet into my struts app but I always get "java.lang.ClassNotFoundException: Main.class"

I tried to copy the jar into web/applets and call it with or
I tried to unpack the jar,place the classes under web/applets/JavaApplication15 and call with
unpack the jar,place the classes under web/applets/ and call with

I even tried to copy Main.class to the same folder where I have the JSP /web/jsp/admin and call with without "archive" or "codebase"

Whatever I try, I always get the ClassNotFoundException. What am I doing wrong!

Thank you!

Dani Acedos

Joined: Apr 18, 2011
Posts: 4
this is the stack of the javaconsole
Tim Moores

Joined: Sep 21, 2011
Posts: 2413
Does https://localhost:8443/Stimula/applets/Applet.jar exist? What happens if you paste that URL into a browser - can you download the jar file?

You should not use an applet's constructor, by the way. An applet's lifycycle is handled by the browser - if you need to do something when the applet is created, override its init() method and put your code there.
Dani Acedos

Joined: Apr 18, 2011
Posts: 4
I checked and yes, and I can download the jar if I paste the url.

I add, I try to run the applet in Firefox, If I try in IE I get another error: java.lang.RuntimeException: java.lang.ExceptionInInitializerError.

Probably due to permissions?

Andrew Thompson
Ranch Hand

Joined: Aug 05, 2010
Posts: 77
Besides all the sage advice offered by Tim, I'll just point out that calling in an applet does not make much sense no matter what the value is.

Andrew Thompson
I agree. Here's the link:
subject: Problem when calling applet
It's not a secret anymore!