M
Mistake
Hello everybody,
I've just spent some hours (late hours) fighting against the classpath
in JAR archives, the MANIFEST.MF file and the INDEX.LIST file.
I just want to mention together some of the information I gathered
through internet (and tested on my own). They may be useful to someone
else. I'm not completely sure to have understood everything, though.
1. You can't launch a Java application using the "java" command, and
using both the -jar (specifies a jar file) option and the -cp
(specifies a classpath) option. They're mutually exclusive. If you use
the -jar option, then the -cp is completely ignored.
2. You can add a 'Class-Path' entry in the manifest file, MANIFEST.MF
file (see http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html). But
you have to be very cautious with it. Several rules apply in the way
you specify your class path:
- Class-Path line can't be longer than 72 chars (nice one).
- You can break a classpath line into several, but you have to make
the line separation as CR[space][space] (see
http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4295946)
- All classpath entries are relatives to the jar archive containing
the manifest.
- A single dot '.' stands for the folder where the jar archive is
placed:
- Classpaths are separated by ' ' (one space).
- The classpath line must be finished by a carriage return (CR, LF,
or CRLF).
3. If there is a INDEX.LIST besides the MANIFEST.MF, then the class
path specified in the manifest is ignored. This can happen if some of
the jar libraries included in your jar have this INDEX.LIST file. When
you build your jar, you have to break up all jar libraries, and
recompile them into one big fat jar. Some (undesirable?) INDEX.LIST may
pop out to the META-INF folder.
The last point took me some time to figure out. In my case, the culprit
was mysql-connector-java-3.1.11-bin.jar.
Regards,
Mistake
I've just spent some hours (late hours) fighting against the classpath
in JAR archives, the MANIFEST.MF file and the INDEX.LIST file.
I just want to mention together some of the information I gathered
through internet (and tested on my own). They may be useful to someone
else. I'm not completely sure to have understood everything, though.
1. You can't launch a Java application using the "java" command, and
using both the -jar (specifies a jar file) option and the -cp
(specifies a classpath) option. They're mutually exclusive. If you use
the -jar option, then the -cp is completely ignored.
2. You can add a 'Class-Path' entry in the manifest file, MANIFEST.MF
file (see http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html). But
you have to be very cautious with it. Several rules apply in the way
you specify your class path:
- Class-Path line can't be longer than 72 chars (nice one).
- You can break a classpath line into several, but you have to make
the line separation as CR[space][space] (see
http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4295946)
- All classpath entries are relatives to the jar archive containing
the manifest.
- A single dot '.' stands for the folder where the jar archive is
placed:
- Classpaths are separated by ' ' (one space).
- The classpath line must be finished by a carriage return (CR, LF,
or CRLF).
3. If there is a INDEX.LIST besides the MANIFEST.MF, then the class
path specified in the manifest is ignored. This can happen if some of
the jar libraries included in your jar have this INDEX.LIST file. When
you build your jar, you have to break up all jar libraries, and
recompile them into one big fat jar. Some (undesirable?) INDEX.LIST may
pop out to the META-INF folder.
The last point took me some time to figure out. In my case, the culprit
was mysql-connector-java-3.1.11-bin.jar.
Regards,
Mistake