Problems with classpath Java Manifest.mf

I'm trying to run a jar file - let it use test.jar, which uses Sybase jconn3.jar on a Unix system.

I created a MANIFEST.MF file that has the following:

Class-Path: $SYBASE/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar 

This gives a ClassNotFoundError. $ SYBASE - a system variable pointing to / opt / sybase 13; I also tried the following:

 Class-Path: /opt/sybase13/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar 

and

 Class-Path: opt/sybase13/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar 

However, if I copy the jconn3.jar file from the $ SYBASE / jConnect-6_0 / classes to the same directory as test.jar, and update my MANIFEST.MF file as follows:

 Class-Path: jconn3.jar commons-net-1.3.0.jar 

The application works as expected.

Now I was able to check if the jconn3.jar file was working by copying it locally; my MANIFEST.MF file includes the path to my main class, so no problem here.

What do you think, maybe the problem? I have been looking at this thing for too long. Thanks!

+3
source share
2 answers

Entries in the class path relate to either the JAR in which they are embedded (which you work with), or are URLs. In order for your absolute paths to work, you need to convert them to URLs, e.g.

file:/opt/sybase13/...

There is no mechanism for using variables.

Although the JAR specification does not make this clear, absolute file: scheme URLs work in the class-path attribute.

+11
source

Environment variables are not read by the AFAIK class loader. However, you can add the jar to the script configuration

In accordance with the specification, the records are not absolute for the bank:

Class path:

The value of this attribute indicates the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to build its internal search path.

http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html # manifest specification

0
source

All Articles