ClassNotFound error while running applet from Web application

hi everyone,

I have a web application deployed in Tomcat web server. I have HTML file at the level of WEB-INF. And all class files under WEB-INF/classes. But while ruuning the application it giving following error.

load: class com.app.AppletTest not found.

java.lang.ClassNotFoundException: com.app.AppletTest

at sun.applet.AppletClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadCode(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)

Caused by: java.io.IOException: open HTTP connection failed.

at sun.applet.AppletClassLoader.getBytes(Unknown Source)

at sun.applet.AppletClassLoader.access$100(Unknown Source)

at sun.applet.AppletClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

... 10 more

Here the HTML file applettest.html

<html>

<head>

<title>Multiple Image Upload</title>

</head>

<body>

<applet code="com.app.AppletTest" width="300" height="300">

</applet>

</body>

</html>

And Java applet file is

package com.app;

import java.applet.Applet;

import java.awt.Color;

import java.awt.Graphics;

public class AppletTest extends Applet

{

public void init()

{

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

this.setBackground(new Color(180,200,250));

}

public void start()

{

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

}

public void paint(Graphics g)

{

g.drawString("welcome Hello World",50,50);

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

}

public void stop()

{

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

}

public void destroy()

{

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

}

}

Thanks.

[2318 byte] By [Appsa] at [2007-11-26 12:22:52]
# 1

Hi,

if u put ur com.app.AppletTest file @ WEB-INF Directry, then this problem will solve easily.

you have to put applet package(com.app.AppletTest) @ WEB-INF Directry. Since

Applet is using by html, u have to keep applet with html file.

if applet class have interaction with other classes, u have to seperate all related class to applet to seperate package and put them @ WEB-INF folder.

Janatha at 2007-7-7 15:22:08 > top of Java-index,Desktop,Core GUI APIs...
# 2
ok, I tried this. It works. Thanks for reply.
Appsa at 2007-7-7 15:22:08 > top of Java-index,Desktop,Core GUI APIs...