Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would I not use a wildcard in my classpath?

Tags:

java

classpath

Are there any disadvantages in using Java 6 wildcards in my classpath ? e.g.

C:> set CLASSPATH=.\lib\*

I can see that where there are two jars that both contain a class with the same path then using a wildcard may lead to results that are hard to track down.

But other than that, is there anything else to be aware of?

like image 232
Paul McKenzie Avatar asked Oct 14 '22 01:10

Paul McKenzie


2 Answers

If it's what you want to do, then do it. As long as you are aware of the consequences. Keep in mind that if anyone else has to maintain the project, they may copy a bunch of jars into that folder not realizing that they'll be linked by default. It shouldn't take them too long to see what's going on, though.

I generally try to minimize the number of jar files I use, and link them all in manually. I realize this is personal preference.

like image 116
Erick Robertson Avatar answered Oct 16 '22 16:10

Erick Robertson


You might load undesired classes by doing so, and if there is two versions of the same library; well, kaboom.

like image 29
Colin Hebert Avatar answered Oct 16 '22 15:10

Colin Hebert