Since Java 1.5 or so, javac has been looking into the manifest of third-party jars to find other jars. This causes a number of undesirable side-effects:
-Xlint:-path
) So I was wondering if anyone knows the magic invocation to disable this. Assuming that Sun didn't saddle us with another feature we didn't want and can't turn off once we have it.
CLASSPATH is an environment variable which tells javac or java where to find the user defined classes it must refer to. CLASSPATH consists of a colon separated list of directories. The directory containing Java system classes will be automatically appended at the end of the list by the system.
In general, to include all of the JARs in a given directory, you can use the wildcard * (not *. jar ). The wildcard only matches JARs, not class files; to get all classes in a directory, just end the classpath entry at the directory name.
To check our CLASSPATH on Windows we can open a command prompt and type echo %CLASSPATH%. To check it on a Mac you need to open a terminal and type echo $CLASSPATH.
In short, Rsrc-Class-Path is an attribute that the JarRsrcLoader class understands, and uses to construct the actual application classpath. In this context, the Class-Path: . attribute serves no real purpose. Everything needed to run JarRsrcLoader will be in the JAR.
Heres an Ant target to modify the manifest files(uses ant-contrib)
<target name="util-modify-manifest" depends="build-classpath">
<for param="file">
<fileset dir="${jars}" >
<include name="**/*.jar" />
</fileset>
<sequential>
<jar jarfile="@{file}" destfile="@{file}" update="true">
<manifest>
<attribute name="Class-Path" value="" />
<attribute name="Export-Package" value="" />
</manifest>
</jar>
<echo message="Manifest Replaced: @{file}" />
</sequential>
</for>
Use bnd or shade to strip the offending MANIFEST.MF entry from the jars, instead of just renaming. Or take advantage of the face that these pathnames are essentially never absolute. If you move the jar named 'i-have-a-ClassPath.jar' into its own subdirectory, the manifest class path entries will fail to find these other jars in the expected locations. I suppose that will still whine if you turn on enough lint, though.
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