Unable to add classpath via command line

I want to add a class path through a command line call. The call is as follows:

java -cp ..\conf -jar ..\lib\switcher.jar 

The conf directory contains an XML file that defines the application context and the log4j.properties file. But when I run this command, Java obviously cannot find these two files, although I added them to the class path.

I also tried to specify the absolute path of the conf directory, but it didn't work either.

Any clues?

+4
source share
2 answers

If you use the -jar parameter, java.exe ignores the class path. He will look only in this bank. Try using the Class-Path manifest instead of forcing Java to look for auxiliary banks.

+7
source

I think your XML file may contain the used ClassPath ...

Unfortunately, the java command does not understand the subtle way to express your class path. You need to give it a list of directories / jar / zip. Any other way to set the classpath will fail.

0
source

Source: https://habr.com/ru/post/1309299/


All Articles