Jar Problems

Hey guys, my first post here so sorry if i mess up badly.

Im having some problems with getting my jars to work, I can get a jar file to be created but its not running and wont extract. so here goes.

I have two projects, one is a library and one is an application, the library is button and the project is an app using said button.

I want a jar that will make the allow the app to run (so i guess the library will need to be jarred too).

Whenever i jar them i get this error

DosPrompt

C:\Uni\StreamSoftwareEngineering\CBSD\Classhole>java -jar meterApp.jar

Exception in thread "main" java.lang.NoClassDefFoundError: MeterInterface (wrong

name: org/Dave/CBSD/MeterInterface)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown 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)

now the source files are in two different files (they are netbeans projects) but they are in the same package. my manifest file looks like this

Manifest

Manifest-Version: 1.0

Main-Class: MeterInterface

Name: MeterInterface.class

Java-Bean: False

Name: MeterButton.class

Java-Bean: True

Can anyone help?

Thanks

CoMa

[1850 byte] By [CoMaa] at [2007-10-3 9:45:30]
# 1

I think you should add class path to your manifest file if you want your jar to use the library.

If MeterInterface is located at org/Dave/CBSD/MeterInterface then you should change your Main-Class to org.Dave.CBSD.MeterInterface.

Manifest-Version: 1.0

Main-Class: org.Dave.CBSD.MeterInterface

Class-Path: button.jar

replace button.jar with the name of your library, and be sure that button.jar is on the same path with meterApp.jar when you run the app.

mimi_tan1985a at 2007-7-15 5:02:10 > top of Java-index,Desktop,Deploying...
# 2

Hey i done that :) now im getting a new error :(

- - - - - -

C:\Uni\StreamSoftwareEngineering\CBSD\Classhole>jar mfc MeterApp.jar manifest.mf

Meterbutton.class MeterInterface.class

java.io.IOException: invalid header field

at java.util.jar.Attributes.read(Attributes.java:389)

at java.util.jar.Manifest.read(Manifest.java:167)

at java.util.jar.Manifest.<init>(Manifest.java:52)

at sun.tools.jar.Main.run(Main.java:123)

at sun.tools.jar.Main.main(Main.java:903)

- - - - - -

My Manifest looks like this

Manifest.mf

Manifest-Version: 1.0

Main-Class: org.Dave.CBSD.MeterInterface

Class-Path: C:\Uni\StreamSoftwareEngineering\CBSD\Classhole

Name: MeterInterface.class

Java-Bean: True

Name: MeterButton.class

Java-Bean: True

- - - - - -

Thanks for the help, can you(or anyone) help me with this? its killing me.

Thanks

CoMa

CoMaa at 2007-7-15 5:02:10 > top of Java-index,Desktop,Deploying...
# 3
For anyone watching this topic, i solved the problem.Some sort of problem with netbeans 5.5 (IE somethings changed and i dont know about it) was making my Jar tool go crazy, so i switched back to NB 4.1 and my source worked fine.
CoMaa at 2007-7-15 5:02:10 > top of Java-index,Desktop,Deploying...