Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad path warning, where is it coming from?

When I compile my project with compiler warnings (JDK 1.5) I get a bunch of bad path element warnings:

Warning:: [path] bad path element "C:\Users\User\MyJava\common\lib\junit.jar": no such file or directory Warning:: [path] bad path element "C:\Users\User\MyJava\common\lib\jdom.jar": no such file or directory Warning:: [path] bad path element "C:\Users\User\MyJava\common\lib\xerces.jar": no such file or directory Warning:: [path] bad path element "C:\Users\User\MyJava\common\lib\xml-apis.jar": no such file or directory

and many more.

This is using IDEA 8.1.3. I can't find anywhere in IDEA's configuration (I grepped the whole project) where anything points to these files. They are all indeed not there anymore under that name, but what references them?

like image 246
Yishai Avatar asked Aug 27 '09 22:08

Yishai


2 Answers

I think @Yishai has the right of it (I'll give him an up-vote for getting the ball rolling). I run into this all the time. In what I think was a horrible decision for the Java language, they decided it would be alright to allow classpath settings to go into the MANIFEST files inside jar files. So essentially, Jars can have files inside them that point to other classes and jars located elsewhere and when those other things they point to don't exist, you see warnings like the ones you're getting. These warnings are coming out of Jar files that are on your compilation classpath. So what you need to do if you really care is track down the problem jar files, extract the contents of the jar files, remove the "Class-Path" settings in their manifest files and recreate them. Something like this (move the jar to a temp directory somewhere first):

#Extract the jar file
jar xvf myfile.jar
rm myfile.jar
emacs ./META-INF/MANIFEST.MF

*Find the entry "Class-path:" and remove it completely and save the changes

#Rebuild the jar file
jar cvf myfile.jar ./*

That should do the trick!

I don't think you just want to suppress these messages because if you want full control over what's going onto your classpath, you should search out these manifest files and make sure they don't mess with the classpath in a way you don't know about.

Likely you'll have to look through a ton of jar files, so I usually end up using a shell loop to help me look through them. You can copy all your Jars in question to a temporary directory and run a loop like this (bash syntax):

for i in *.jar; do echo $i; jar xf $i; grep -i 'class-path' ./META-INF/MANIFEST.MF; done

That will print the name of every Jar file in the current directory, extract its contents, and grep its manifest file for classpath entries. If the name of the jar file in the output has a "Class-Path" printout after it, that means that Jar has classpath settings in its manifest. This way you can hopefully figure out what Jars you need to take action on.

like image 59
Brent Writes Code Avatar answered Nov 14 '22 02:11

Brent Writes Code


According to this, the issue is that in third party jars there is a reference to these in the manifest. The message can be disabled by adding -Xlint:-path to the compilation parameters.

like image 28
Yishai Avatar answered Nov 14 '22 01:11

Yishai