Java .jar - NoClassDefFound problems

Associate
Joined
22 Jul 2004
Posts
230
Location
Nottingham, UK
I've done a Java project using netbeans using the JDK1.5.
It builds and creates a jar file which runs fine on my pc.

However when I move it to the uni computers it doesn't work:
(The uni computers hav JDK1.4 installed with netbeans 5.0RC2, but they also have JRE1.5)
I get the following error

>java -jar CarHire.jar
------ Starting Client Mode ------
Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
at CarHire.Main.main(Main.java:29)

It creates the following in the dist directory

/dist/CarHire.jar
/dist/lib/swing-layout-1.0.jar
/dist/lib/AbsoluteLayout.jar

The jar runs fine on my pc.

Does anyone know how to get it to run?
 
Rossmac said:
ask the uni to update to 1.5? I think GroupLayout changed a bit going from 1.4 to 1.5
They can't/won't. Due to the amount of red tape just to get anything installed.

SoapSurgeon said:
Have you set up your classpath correctly on the uni machines?
What is the correct class path to use?
 
Ah I can help here. GroupLayout unfortunately is not part of the standard libraries. You'll have to get hold of the swing-layout.jar file and put that in your classpath.

edit- oops just realised you are including that file. Well you just have to make sure it's in the classpath when you run the jar.
 
adam3223 said:
What is the correct class path to use?

I havent done java in a while but you have to make sure that all the jars you use are in your classpath so that when java tries to run your program it knows where to look for them.
 
I've played around with the classpath but still can't get it to run:

the Manifest file inside the jar contains the following:
Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.6.0-b105 (Sun Microsystems Inc.)
Main-Class: CarHire.Main
X-COMMENT: Main-Class will be added automatically by build
Class-Path: lib/swing-layout-1.0.jar
 
i suggest you look at line 29 in your main method (like the error tells you) to see what part it is having trouble with. You might be able to narrow it down to a particular jar that way.
 
line 29 is basically
frm = new frmMain();

frmMain() errors out at the layout code for the form.
I'm sure its just not finding the GroupLayout class.
 
Use the explicit path to the 1.5 JRE, it will be an updated API problem.

Since the old JRE is also included in the JDK, it's probably calling the old since it will be in the environment paths.
 
Back
Top Bottom