wood burning stoves 2.0*
The moose likes Java in General and the fly likes manifest.mf classpath not working in unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "manifest.mf classpath not working in unix" Watch "manifest.mf classpath not working in unix" New topic
Author

manifest.mf classpath not working in unix

rajesh sherla
Greenhorn

Joined: Apr 04, 2010
Posts: 11
Hi,

I developed program which connects to database and uses ojdbc14.jar. I have included below mentioned entries in Manifest.mf file :

Class-Path: lib/ojdbc14.jar lib/jxl.jar lib/poi-3.6.jar
Main-Class: com.xl.MainExcel

And the library files are included inside the "lib" folder in the newly created jar file.

Problem is, this program runs fine in Windows environment, but in UNIX environment, the same program gives exception "Class not found: com.oracle...."

Why so ???

Not able to figure it out. Can anybody help me how to run the same jar file in unix environment ??
Not only this other programs which requires external library files never work in unix machines whereas same works fine in Windows environment.

My requirement is, if my program requires any external jar file then i should not tell my client to include those files in respective directory, the jar file which i will be providing should run fine with the help of manifest.mf enties.

Thanks,
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2248
    
  47
The standard classloader (certainly up to ver 1.6, not sure about ver .7) does not support loading classes from jars within jars. There are class loaders available that do support this functionality and I believe some IDE's such as Eclipse can package jars in jars by providing such a classloader.
If your jar is working on Windows and not Unix it may be picking up the classes from external jars without you realising it.
rajesh sherla
Greenhorn

Joined: Apr 04, 2010
Posts: 11
Tony Docherty wrote:The standard classloader (certainly up to ver 1.6, not sure about ver .7) does not support loading classes from jars within jars. There are class loaders available that do support this functionality and I believe some IDE's such as Eclipse can package jars in jars by providing such a classloader.
If your jar is working on Windows and not Unix it may be picking up the classes from external jars without you realising it.


Yes, you may be correct.
But m sure that in "Windows" there is nowhere specified to pickup the required jar files. Thus there is no way that java program(Windows OS) is picking up the jar files from external source.


Can you tell me about how to load the jar files within jar ?? i.e. which utility to use , any example etc....


Thanks,
Siva Vulchi
Ranch Hand

Joined: Nov 17, 2011
Posts: 30
Can you tell me about how to load the jar files within jar ?? i.e. which utility to use , any example etc....


As per my knowledge, we can not have jar files inside a jar file.

If your jar file has some dependencies, then place those in any directory and use manifest file with Class-Path to refer those dependencies by specifying relative path or absolute path.

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2248
    
  47
As per my knowledge, we can not have jar files inside a jar file.

You are correct in that the standard class loader does not support this. However, as per my earlier post, there are class loaders that can do this.

Try googling for something like "java jar in jar class loader" or read this blog http://qdolan.blogspot.co.uk/2008/10/embedded-jar-classloader-in-under-100.html.
Note: I'm not recommending this code, I've neither used it nor even studied it, I've just included the link as an example.
Siva Vulchi
Ranch Hand

Joined: Nov 17, 2011
Posts: 30
Try googling for something like "java jar in jar class loader" or read this blog http://qdolan.blogspot.co.uk/2008/10/embedded-jar-classloader-in-under-100.html.


Thanks for sharing!!! That blog was nice and good to know about it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: manifest.mf classpath not working in unix