NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Applet works in applet viewer, not in browser

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
aescott



Joined: 01 Dec 2008
Posts: 3
Location: Glasgow, UK

PostPosted: Thu Jun 25, 2009 2:22 pm    Post subject: Applet works in applet viewer, not in browser Reply with quote

I'm running NetBeans 6.5.1 on openSuse 11.0 32 bit (if that helps).

I'm planning on deploying a java program as a web tool, but thought I ought to have a go at a simple applet first. Good idea, because it doesn't work....

The applet works in the applet viewer; however, I get an error with the browser.

Here is the applet code:

Code:
package WebTest;

import javax.swing.JApplet;
import java.awt.Graphics;

public class HelloWorld extends JApplet
{
   public void paint(Graphics g)
   {
      g.drawRect(0, 0, getSize().width -1, getSize().height - 1);
      g.drawString("Hello, World!", 5, 15);
   }
}


...and here is the output from the Console:

Code:

java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
   at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:140)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:409)
   at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:2825)
   at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1380)
   at java.lang.Thread.run(Thread.java:619)
Exception: java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)


Can anyone tell me what I'm doing wrong? I expect it's something really basic.

For your info, the website is
http://www.1stbothwell.org/

Thanks in anticipation.
Back to top
Melongo Annabel
Posted via mailing list.





PostPosted: Sun Jun 28, 2009 11:16 pm    Post subject: Applet works in applet viewer, not in browser Reply with quote

You should add an "init" method to your applet. That's the method that gets called when the applet starts. I think that's what it is complaining about.


From: aescott <address-removed>
To: address-removed
Sent: Thursday, June 25, 2009 9:22:53 AM
Subject: [nbj2ee] Applet works in applet viewer, not in browser

I'm running NetBeans 6.5.1 on openSuse 11.0 32 bit (if that helps).



I'm planning on deploying a java program as a web tool, but thought I ought to have a go at a simple applet first. Good idea, because it doesn't work....



The applet works in the applet viewer; however, I get an error with the browser.



Here is the applet code:




Code:
package WebTest;



import javax.swing.JApplet;

import java.awt.Graphics;



public class HelloWorld extends JApplet

{

public void paint(Graphics g)

{

g.drawRect(0, 0, getSize().width -1, getSize().height - 1);

g.drawString("Hello, World!", 5, 15);

}

}







...and here is the output from the Console:




Code:


java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:621)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:140)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:409)

at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:2825)

at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1380)

at java.lang.Thread.run(Thread.java:619)

Exception: java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)







Can anyone tell me what I'm doing wrong? I expect it's something really basic.



For your info, the website is

http://www.1stbothwell.org/



Thanks in anticipation.
Back to top
rivasdiaz



Joined: 14 Jul 2009
Posts: 2

PostPosted: Tue Jul 14, 2009 7:36 pm    Post subject: Your problem is on the HTML page Reply with quote

Your problem is probably in the HTML, as the error mention webtest/HelloWorld and I doubt that your class is inside a package named webtest, which is probably the name of the project, not the package. Check your applet tag in the HTML file.

This could also help you:

http://java.sun.com/docs/books/tutorial/deployment/applet/index.html
Back to top
sock_osg



Joined: 21 Jul 2009
Posts: 1

PostPosted: Tue Jul 21, 2009 5:29 pm    Post subject: Re: Applet works in applet viewer, not in browser Reply with quote

aescott wrote:
I'm running NetBeans 6.5.1 on openSuse 11.0 32 bit (if that helps).

I'm planning on deploying a java program as a web tool, but thought I ought to have a go at a simple applet first. Good idea, because it doesn't work....

The applet works in the applet viewer; however, I get an error with the browser.

Here is the applet code:

Code:
package WebTest;

import javax.swing.JApplet;
import java.awt.Graphics;

public class HelloWorld extends JApplet
{
   public void paint(Graphics g)
   {
      g.drawRect(0, 0, getSize().width -1, getSize().height - 1);
      g.drawString("Hello, World!", 5, 15);
   }
}


...and here is the output from the Console:

Code:

java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
   at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:140)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:409)
   at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:2825)
   at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1380)
   at java.lang.Thread.run(Thread.java:619)
Exception: java.lang.NoClassDefFoundError: HelloWorld (wrong name: webtest/HelloWorld)


Can anyone tell me what I'm doing wrong? I expect it's something really basic.

For your info, the website is
http://www.1stbothwell.org/

Thanks in anticipation.
Back to top
ntraider



Joined: 23 Jul 2009
Posts: 2
Location: Fort Worth, TX

PostPosted: Thu Jul 23, 2009 10:47 pm    Post subject: Reply with quote

Aescott, did you ever solve this issue? I am having a similar issue and it is frustrating to say the least. Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo