• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

manifest.mf classpath not working in unix

 
rajesh sherla
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic