• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

java: ClassNotFoundException

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I have written a simple applet which looks like:
-----------------------------------------------------------
import java.applet.Applet;
import java.awt.Graphics;
public class FirstApplet extends Applet
{
public FirstApplet()
{
}
public void paint(Graphics g)
{
g.drawString("Hellow World", 25, 50);
}
-----------------------------------------------------------
And to run this applet the required html code is
-----------------------------------------------------------
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<APPLET CODE="FirstApplet.class" width="150" height="150">
</APPLET>
</BODY>
</HTML>
-----------------------------------------------------------
On Local machine when I am trying to open the html file, it loads the applet and works fine.
But now if I am putting all these on server (Apache-Tomcat) and trying to execute it then it gives me the error in java console as:
Java(TM) Plug-in: Version 1.4.0_03
Using JRE version 1.4.0_03 Java HotSpot(TM) Client VM
User home directory = C:\WINNT\Profiles\am007431.MAHINDRABT
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system properties
t: dump thread list
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class FirstApplet.class not found.
java.lang.ClassNotFoundException: FirstApplet.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at sun.plugin.security.PluginClassLoader.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)
... 11 more

------------------------------------------------
I put my class file in '/WEB-INF/classes' folder and instead of html page I am using jsp page which is in '/jsp' folder.
Can any one help me out to solve this problem.
It's urgent !
Thanks in advance..
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/WEB-INF/classes
is for classes used by the servlets and/or JSPs. It's not the place to put applet code. Try putting the applet class in the same dir as the jsp (is the /jsp folder).
A better idea even would be to have /jsp and /applet directories. Put hte jsp in the /jsp dir and put the applet code in the /applet dir then in the jsp you would have:

Brian
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic