I am trying a simple index creation on a jar file. However it fails with:
$ jar -i /tmp/vtk-dicom/bin/lib/vtkdicom.jar
java.io.FileNotFoundException: /tmp/vtk-dicom/bin/lib/vtk.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:154)
at java.util.jar.JarFile.<init>(JarFile.java:91)
at sun.tools.jar.Main.getJarPath(Main.java:1052)
at sun.tools.jar.Main.getJarPath(Main.java:1068)
at sun.tools.jar.Main.genIndex(Main.java:1084)
at sun.tools.jar.Main.run(Main.java:269)
at sun.tools.jar.Main.main(Main.java:1177)
On obvious work-around is simply:
$ cp /usr/share/java/vtk.jar /tmp/vtk-dicom/bin/lib/
However it is ugly and error-prone. Is there any other way I can tell jar -i
where to search for a different vtk.jar
location ? I will need a portable solution which works on Windows/Linux/MacOSX.
For information the manifest is set to:
$ cat ./Source/java/manifest.txt
Class-Path: vtk.jar
For information, if I change it to:
$ cat ./Source/java/manifest.txt
Class-Path: /usr/share/java/vtk.jar
It gives a slightly different error:
$ jar -i /tmp/vtk-dicom/bin/lib/vtkdicom.jar
java.io.FileNotFoundException: /tmp/vtk-dicom/bin/lib/usr/share/java/vtk.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:154)
at java.util.jar.JarFile.<init>(JarFile.java:91)
at sun.tools.jar.Main.getJarPath(Main.java:1052)
at sun.tools.jar.Main.getJarPath(Main.java:1068)
at sun.tools.jar.Main.genIndex(Main.java:1084)
at sun.tools.jar.Main.run(Main.java:269)
at sun.tools.jar.Main.main(Main.java:1177)
For reference:
$ java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-2)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
I haven't found any documentation on this, but it seems to work if you provide the other jars after the main jar:
jar -i main.jar other.jar
For your example:
cd /tmp/vtk-dicom/bin/lib/
jar -i vtkdicom.jar /usr/share/java/vtk.jar
The other jar files are not modified. No changes are needed for the manifest.
Edit:
The generated INDEX.LIST file contains the full path that you specify for "main.jar", so I've modified my example to "cd" into the directory first. Otherwise, the jar file might not work after it is installed in its final location.
Alternatively, "jar -i" can be run on the file after it is installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With