The Java documentation is fairly explicit in how to define multiple classpath directories (delimited by ; or : depending on OS).
However, I have a situation where a framework is already setting the -cp flag to an application directory. I have the ability to add additional options to the command line, so I was wondering why I can't add my own additional -cp option that specifies my path.
Will this automatically combine the classpath entries, or will it result in only one of the two entries being used? If the latter, which one will be used?
Experiment has shown that the Java CLI doesn't complain if you specify -cp or -classpath multiple times.
However, the result is that whatever classpath was set last will override any previous arguments. Thus:
java -cp lib1/* -cp lib2/* MyProgram
will result in only the "lib2" classes being on the classpath
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