Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error (NoClassDefFoundErro) loading applet in Safari

 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using Netbeans 7.3, JRE 1.7.0_11, Java SE 7 update 40, on Mac 10.8.5.
I have created a JApplet GUI form which I have embedded in a applet tag within a HTML doc,
which I have created in a Java Wed application.
We I try to run in Safari I get the following error:

java.lang.NoClassDefFoundError org/jdesktop/layout/GroupLayout$Group

I have searched the net found that some people resolved this error by changing :
Prefernecs-Java-GUI Builder - Layout Generation Style from Automatic to Swing Layout Extension Library. (from Automatic)

But I am still getting the same error.
Any feedback appreciated.

Cheers
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you made the changes, did you recompile and rebuild and retest (after clearing the browser cache?)
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope but I soon will
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but still the same error despite rebuilding project and clearing the cache.

Is there a rule about posting the sane question on different forums? Have been stuck with this problem for a week or so and was thinking posting on stack overflow.
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

org.jdesktop is not part of the standard java api.
From the error looks like your external jar which includes this class is not on the classpath.
I dont use netbeans or drag and drop style UI builders (it is always best to hand code) so I cannot offer you further assistance on how to fix this error. The way to fix this error is using the standard java api group layout, or better yet hand coding and specifying your own layouts.

Is there a rule about posting the sane question on different forums? Have been stuck with this problem for a week or so and was thinking posting on stack overflow.

There is no rule which says you cannot post to other forums. All we expect is a courtesy telling us you have.
Read more about it here https://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Well I tried adding the class by including swing-layout-1.0.4 jar file to the archive tag:



but then I have a separate issue where the org.me.hello.MyApplet2 class could not be found, this is the package.appletFile.class, so out of ideas there (I have posted thos query on netbeans communoity forum also to get some insight, it seems allot of people have this issue!!).

Anyways as you suggested I re-wrote the applet in text editor without the GUI builder & netbeans, saved the .java file to desktop, compiled through command line, and also put the HTML doc on the desktop (so HTML, clsss file all in same directory). However now the applet still dosent load and there are no errors on the console.
When the applet tag is highlighted in the web inspector it the applet displays as "applet 0px 0px".



 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the applet tag is highlighted in the web inspector it the applet displays as "applet 0px 0px".

Looks like you forgot to specify the width and height attributes
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had added width="300" height="200" and got the same : applet 0px 0px
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your SSCCE applet code along with the html (dont forget to UseCodeTags)
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Maneesh:
Applet/Object code (tried both, same result):


All files are in the same directory (on my desktop), could not attach so have included teh java code:


Cheers
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uh oh!
There are so many things wrong with this code. You are mixing up console stuff (e.g. Scanner) with the applet GUI. For asking user input, you should be using proper GUI components e.g. JTextField.
I would really suggest you stop and go through http://docs.oracle.com/javase/tutorial/uiswing/components/applet.html

 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should if nade thst clear.
the scanner is never used and all console
references have been commented out, i just forgot to comment out the import. Instead i used JOptionpanes which I've seen used in applets before, also the applet works ok in apple viewer
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't edit the code above so an posting
edited code with console code comments removed
Removing comments/refs to console code made no diff, still no applet



 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have also posted on netbeans (pending) and stackoverflow.
 
Ciaran Mooney
Ranch Hand
Posts: 74
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have discovered the basic applets (no GUI) work in any PC/OS but mine!
I have checked the security settings for java and they are set to medium, any ideas?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic