GeeCON Prague 2014*
The moose likes Applets and the fly likes Error (NoClassDefFoundErro) loading applet in Safari Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "Error (NoClassDefFoundErro) loading applet in Safari" Watch "Error (NoClassDefFoundErro) loading applet in Safari" New topic
Author

Error (NoClassDefFoundErro) loading applet in Safari

Ciaran Mooney
Ranch Hand

Joined: Jan 21, 2013
Posts: 72

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

I love deadlines, I love the whooshing sound they make as they fly by...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

After you made the changes, did you recompile and rebuild and retest (after clearing the browser cache?)


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ciaran Mooney
Ranch Hand

Joined: Jan 21, 2013
Posts: 72

Nope but I soon will
Ciaran Mooney
Ranch Hand

Joined: Jan 21, 2013
Posts: 72

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

Joined: Jul 26, 2007
Posts: 10426
    
    8


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

Joined: Jan 21, 2013
Posts: 72

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

Joined: Jul 26, 2007
Posts: 10426
    
    8

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

Joined: Jan 21, 2013
Posts: 72

I had added width="300" height="200" and got the same : applet 0px 0px
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Please post your SSCCE applet code along with the html (dont forget to UseCodeTags)
Ciaran Mooney
Ranch Hand

Joined: Jan 21, 2013
Posts: 72

@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

Joined: Jul 26, 2007
Posts: 10426
    
    8

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

Joined: Jan 21, 2013
Posts: 72

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

Joined: Jan 21, 2013
Posts: 72

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

Joined: Jan 21, 2013
Posts: 72

Have also posted on netbeans (pending) and stackoverflow.
Ciaran Mooney
Ranch Hand

Joined: Jan 21, 2013
Posts: 72

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error (NoClassDefFoundErro) loading applet in Safari