• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jar File Not Accepting my Classpath As specified in the manifest.mf

 
Chetan Pandey
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:

I think this is a MANIFEST.MF syntax Issue.

I have a Jar File dict.jar.

When I run it using :

java -jar dict.jar


It doesnt work and throws an Exception that one of the Class Files from a dependency jar is missing.

However, if I unzip everything and then run it using the following syntax:

java -cp ./lib/*; com.dictionary.dict.MWSktEngDictionary


it works.

My MANIFEST.MF looks likes the following:



Thanks.

Chetan


PS. Also, if you guys dont mind, I can never run a JAR File on my Windows Vista directly by clicking on it, I always have to go to the Cmd Prompt and do
java -jar name.jar


 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That classpath in the manifest looks suspect.
Set up an association between .jar and javaw (or javaw.exe) in Windows.
 
Paul Clapham
Sheriff
Posts: 21119
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That classpath in the manifest looks suspect.

In particular the back-slashes. Try using ordinary slashes to separate files.

Also I notice you're using the Java 6 version of the classpath which accepts "*" to mean "all jars in the directory". Perhaps that doesn't work in jar manifests. Anyway you've only got one helper jar so it shouldn't be too hard to name it specifically in the manifest.
 
Chetan Pandey
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:

I have tried every combination for the Class-Path


Class-Path: .//lib//sandhi.jar
Class-Path: ./lib/sandhi.jar;
Class-Path: /lib/sandhi.jar
Class-Path: lib/sandhi.jar
Class-Path: lib/sandhi.jar;


Each Time I am told the Dependency from sandhi.jar is missing.

Also, I set an association with .jar file to open with javaw, this ends up giving me a msg:

Couldnot find the Main Class: jarFIleName.jar !!!


 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your manifest file end with a new line character?
 
Chetan Pandey
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it ends with a NewLine Character.

So, in EditPlus I see four lines.

The first three lines have text and the fourth line is an empty line
 
Paul Clapham
Sheriff
Posts: 21119
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chetan Pandey wrote:
Hi:

I have tried every combination for the Class-Path


Class-Path: .//lib//sandhi.jar
Class-Path: ./lib/sandhi.jar;
Class-Path: /lib/sandhi.jar
Class-Path: lib/sandhi.jar
Class-Path: lib/sandhi.jar;


Each Time I am told the Dependency from sandhi.jar is missing.


Did you know that what you have put there means that if the jar file is in directory X, then you need have a directory X/lib containing the sandhi.jar? That's different to your example where you used the -classpath option; in that case the "./lib" is relative to the current working directory.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you have been through tutorials, etc?
 
Chetan Pandey
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the Tutorials clarified something which I had been unclear for a long long time.

Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.


So that implies their is no native out-of-the-box mechanism in Java to read jar from within the jar.

And yes when my java - jar myjar.jar were working , it was located on the same folder which also had the /lib folder.

But moving the myJar.jar to another place, the jar invocation didnt work.

Thanks all for your help, so I have now learnt a important tip on classpaths in Jar Files.

Regards,

Chetan
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to consider OneJar then
http://one-jar.sourceforge.net/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic