469,644 Members | 1,982 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

Error while running Applet

Hi All

I got a problem in running java programs.

i am not able to run java applet while running i got a problem as
Loading Java Applet Failed

java.lang.NoClassDefFoundError: App (wrong name: src/App)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
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)

myhtml file is like this

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5.  
  6. <title>My Applet</title>
  7.  
  8.  
  9.  
  10. </head>
  11.  
  12.  
  13. <body>
  14.  
  15. <h1>Network Applet</h1>
  16.  
  17. <APPLET CODE="App.class" CODEBASE = "\src"  WIDTH=200 HEIGHT=50>
  18.  
  19.  
  20. </APPLET>
  21.  
  22.  
  23.  
  24. </body>
  25.  
  26. </html>
  27.  

the App.java file is



App.java



Expand|Select|Wrap|Line Numbers
  1.  
  2. package src;
  3.  
  4.  
  5.  
  6. import java.awt.*;
  7.  
  8. import java.applet.*;
  9.  
  10. import javax.swing.JApplet;
  11.  
  12. public class App extends JApplet
  13.  
  14. {
  15.  
  16. public void paint(Graphics g)
  17.  
  18. {
  19.  
  20. g.drawString("Hello",100,100);
  21.  
  22. }
  23.  
  24.  
  25. }
  26.  
  27.  
I kept the html file and App.class file in src directory...
so that i specified the CODEBASE in html file like CODEBASE = "\src"
i changed this in so many ways also but no use
i specified complete path of .class file also but it was not run for me..

my directory structure is

src----
app.java
app.class
myhtml.html

Iam using ant to build application so that i also set path to ant...



my jdk path settings are



CLASSPATH

C:\j2sdk1.4.2_12\bin;C:\j2sdk1.4.2_12\lib;





path

C:\ant\bin;C:\j2sdk1.4.2_12\bin;



JAVA_HOME

C:\j2sdk1.4.2_12



ANT_HOME

C:\ant

can anybody help me...
Mar 8 '07 #1
0 1314

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Jeff T. | last post: by
3 posts views Thread by Al | last post: by
1 post views Thread by rajesh | last post: by
1 post views Thread by jindalily | last post: by
7 posts views Thread by adrian.bartholomew | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.