0

I see a lot of opensource project use -cp as

java -cp "libs/a.jar:libs/b.jar:libs/c.jar"

instead of

java -cp "libs/*"

Are there any reason?

Ryan
  • 10,041
  • 27
  • 91
  • 156
  • This an approved standard. Also this is a duplicate that has been asked a number of times, do your research first. http://stackoverflow.com/questions/147454/why-is-using-a-wild-card-with-a-java-import-statement-bad – Dave Jun 16 '14 at 14:56
  • @Dave That question is imports, not classpath. Also, `import` is just syntactic sugar--it doesn't change anything about your compiled classes, it doesn't change the size or nature of your bytecode. – Dave Newton Jun 16 '14 at 15:00

1 Answers1

1

The ability to import via wildcards wasn't available until Java 6 (IIRC).

I prefer explicit dependencies since you know what you're actually using, and can avoid importing potentially conflicting jars, but for simple apps it's not really an issue.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302