Results 1 to 7 of 7
  1. #1
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default 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.
    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 :rolleyes:
    TIA
    scott

  2. #2
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    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....

  3. #3
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    Thanks folks....

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

    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 02:40 PM.

  4. #4
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    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:

    java.lang.NullPointerException
    at java.io.File.<init>(Unknown Source)
    at weblinktool.help.AppInfo.loadInfo(AppInfo.java:69)
    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 02:50 AM.

  5. #5
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    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 02:51 AM.

  6. #6
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    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.

  7. #7
    scotter59 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    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......

Similar Threads

  1. Replies: 2
    Last Post: 07-21-2012, 01:15 AM
  2. java.lang.NoClassDefFoundError: com.ibm.ws.orb.GlobalORBFactory
    By hawkeye in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 06-16-2008, 10:56 AM
  3. java.lang.NoClassDefFoundError
    By bizmut in forum Eclipse
    Replies: 3
    Last Post: 06-15-2008, 12:54 AM
  4. java.lang.NoClassDefFoundError
    By J_a_y in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 11:51 AM
  5. java.lang.NoClassDefFoundError
    By fred in forum Advanced Java
    Replies: 3
    Last Post: 08-01-2007, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •