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?
 
Soldato
Joined
18 Oct 2002
Posts
8,444
Location
Leamington Spa
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.
 
Associate
Joined
14 Apr 2003
Posts
1,101
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.
 
Associate
OP
Joined
22 Jul 2004
Posts
230
Location
Nottingham, UK
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
 
Associate
Joined
14 Apr 2003
Posts
1,101
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.
 
Associate
Joined
5 May 2007
Posts
21
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