0

I'm trying to deploy Java Web Application (Spring, Hibernate, Maven, Tomcat, WinXp) with a very simple applet, but when I open jsp page with this applet I see ClassNotFountException Error.

The structure of my project (deployed):

myApp     
|--META-INF
|--WEB-INF
   |--classses
      |--ru
         |--mydomain
            |--applet
               |--FileChooserApplet.class
   |--views
      |--main.jsp
      |--index.html
|--resources

FileChooserApplet.class:

package ru.mydomain.applet;

import java.applet.Applet;

public class FileChooserApplet extends Applet {

    @Override
    public void paint(java.awt.Graphics g) {
        g.drawString("Weather is good!", 70, 70);
    }
}

main.jsp:

...
<body>
   <APPLET code="ru.mydomain.applet.FileChooserApplet.class"
           codebase="../classes" width=350 height=200></APPLET>
...
</body>
..

I tried to change codebase attribute to:

  • "classes"
  • "/classes"
  • ""
  • delete this attribute

But, if i add the same code for applet to index.html and double-click on this file (URL in browser starts with file:///C:/projects/myApp/target/myApp/...) then applet works.

1
  • "..with a very simple applet," No such beast. At least, not when it comes to deploying them, as you have begun to discover. Commented Jul 25, 2013 at 14:40

1 Answer 1

4

AFAIK the applet will not have access to class files in WEB-INF/classes. These classes can only be accessed by server side resources such as servlets (as opposed to downloadable/static content).

You can jar all the class required for the applet to work and place the JAR file in the views folder. Your applet tag will look like

<APPLET code="ru.mydomain.applet.FileChooserApplet.class" 
        archive="mynewjar.jar"
        width=350 height=200>
</APPLET>

A single JAR file is a cleaner way to do deployments.

Sign up to request clarification or add additional context in comments.

2 Comments

I made jar file with applet class, replaced it into resources folder, added attribute archive="resources/myApplet.jar" to <applet> tag and it works! Thank you!
Thank you, other answers had the codebase attribute instead of archive and that changed got it working for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.