Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2008, 01:13 AM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
I had written a Swing Java file that displays a javax.swing.JFrame by hand, text editor. This Java file works.

Recently I decided to re-write the application as a NetBeans project and in the process I recreated the JFrame, again it works in NetBeans environment, no errors, no problem. I then did a build and tried to run the generated "jar", at this time the following error occurred.
Quote:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
I changed the project properties to run the original JFrame that I had written by hand and it worked both within the environment and from the "jar".

The new JFrame version does reference some other class files within the project, but usually incorrect references appear.....
  • Any ideas how to address this little problem ?
  • What would I focus on to work this/these type of issues out ?
Product Version: NetBeans IDE 6.1 (Build 200804211638)
Java: 1.6.0_06; Java HotSpot(TM) Client VM 10.0-b22
System: Linux version 2.6.18.8-0.1-default running on i386; UTF-8; en_US (nb)
Userdir: /home/scooter/.netbeans/6.1

I am sure that this is another silly programmer issue.
By the way Hi folks
TIA
scott
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-02-2008, 01:58 AM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Okay a little vague maybe, but without a peer review the specific problem would not be identified.

The question is what type of problem would manifest itself when the "jar" is executed but not in the NetBeans environment ? Are there compiler/execution options that would help to identify such a problem ?

If it was environmental then why would a "non-compliant" (handmade) JFrame work which also contains the "GroupLayout", but the "compliant" (generated by NetBeans) one fail ?

I read that it could be in the manifest file which has only two lines in it the Version and X-COMMENT.

Very frustrating in that I use this little app in both my Linux and Windows 2000 environment and would prefer what it had evolved into over my original version.

The alternative approach would be to create a new project and harvest the code, been there done that before. I was hoping this esteemed group could expand my knowledge, plus it gave me an excuse to join a community....
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-03-2008, 03:27 PM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Thanks folks....

Added the compiler option "-Xlint:unchecked" which provided greater detail of the message.

Quote:
Exception in thread "main" java.lang.UnsupportedClassVersionError: weblinktool/j
fWebLinkEntry (Unsupported major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Apparently I was running an old version of Java <duh - a path failing and dependency of the JFrame Netbeans construct on the new jre/jdk>. It was kind of odd since I had recently upgraded to NetBeans 6.0.1 and had included the jre/jdk. Will have to check to see what is going on with my Linux machine, figured this out on Windows 2000 had some time to muck around, if this is is the problem there also (same message - probably is).

I had assumed that I was making some basic brain fart.
Funnier still, had addressed similar issues before in my Java development, usually though those were cases where NetBeans had problems also - eh, turned into a grip about meaningful error messages...
Thanks folks....

Last edited by scotter59 : 07-03-2008 at 03:40 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-03-2008, 08:43 PM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Windows 2000

Okay obviously I had a Java version problem, NetBeans was using jdk1.6.0_05 and my classpath for java was Oracle's 1.4 I believe.

Running the application with jdk1.6.0_05 java.exe allowed it to run. However when I attempt to access a resource within the jar that NetBeans has created it returns an error:

Quote:
java.lang.NullPointerException
at java.io.File.<init>(Unknown Source)
at weblinktool.help.AppInfo.loadInfo(AppInfo.java:69)
Quote:
String _xmlfilepath;
URL _urlinfo;
_urlinfo = _appinfo.getClass().getResource("myxmlfile.xml");
_xmlfilepath = _urlinfo.toURI().getPath();
File flAbout = new File(_xmlfilepath);
The "toURI().getPath()" is setting "_xmlfilepath" to null.
I verified this by writing out the results from the "getResource", System.out.println(_urlinfo.getFile().toString()).

This means that I am still not doing something right to run it from the "jar".
I assume that I am not referencing "java.net" correctly somewhere, somehow ? or another brain fart.

Last edited by scotter59 : 07-04-2008 at 03:50 AM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-04-2008, 03:25 AM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Linux

Recreated the same problem with the resource error on Linux running from the most recent Java release.

/usr/local/jdk1.6.0_06/bin/java -jar "myexecutable.jar"

My $JAVA_HOME is pointing to "/usr/lib/jvm/java" where java is a symbolic link to a legacy version.
  • I can change the "java" symbolic link in the "jvm"
  • I can change the environment variables.
  • Try to find out how to manage the Java Virtual Machine.
  • Try to figure out how to run the application from a "makefile" or other construct.
Which is best practices, who knows......

Regardless of these solutions I do not know what the "getresource" needs to function as it does from within the NetBeans environment.

Last edited by scotter59 : 07-04-2008 at 03:51 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-05-2008, 01:49 AM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Linux

Riddle me this - How can one change the Java Virtual Machine configuration to point to the current version of Java installed.

The JVM is pointing to an old version of Java
"java version "1.5.0_10""
I also have installed and NetBeans sees:
Java: 1.6.0_06; Java HotSpot(TM) Client VM 10.0-b22

I could use the brute force method of cleaning out "/usr/lib/jvm", I assume that there is a better method of changing this.

The following things are upsetting:
  • I followed the instructions NetBeans provided in their build list to run my application. There is still some issues with the functionality (getResource). Is this a difference between accessing files within a "jar" and the development environment ?
  • There is no apparent handle on this Java Virtual Machine. Netbeans should provide some sort of handle on this JVM, it may be there, I just have not found it yet.
  • Also my problems are those of a novice in this environment, yet this community did not identify my original "classdef" issue with a list of possible approaches, things to identify or even a link where someone else had addressed it. Figured the latest would provide some sort of positive response like - yo go here read about JVM or run such and such to configure.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-10-2008, 08:28 PM
Member
 
Join Date: Jul 2008
Posts: 12
scotter59 is on a distinguished road
Of course my original problem was Netbeans was using Java 1.6.0_06 and when I ran it directly it the JVM environment variables were pointing to 1.5.0_10 - of course it did not work.

I had assumed that when I installed NetBeans IDE 6.1 with the JDK and JRE these too would be configured, maybe I missed an installation option.....

The "getResource" and trying to write back into a Jar file - apparently this cannot be done as a symmetrical process, read and write. One can re-write the jar or save the file outside the application after the user has modified it, the original in the jar used as a template. This tidbit was found in some blog.

Thanks folks......
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java.lang.NoClassDefFoundError: com.ibm.ws.orb.GlobalORBFactory hawkeye Enterprise JavaBeans 1 06-16-2008 11:56 AM
java.lang.NoClassDefFoundError bizmut Eclipse 3 06-15-2008 01:54 AM
java.lang.NoClassDefFoundError J_a_y New To Java 2 08-07-2007 12:51 PM
java.lang.NoClassDefFoundError fred Advanced Java 3 08-01-2007 06:00 PM
java.lang.NoClassDefFoundError: javax/activation/DataSource bbq Advanced Java 1 07-05-2007 05:26 AM


All times are GMT +3. The time now is 10:22 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org