How to avoid printing file not found exception (..\conf\log4j.xml) with complete stack trace while running the below command. I need to handle this exception and print message instead of complete stack trace.

"java -jar -Dlog4j.configuration="file:..\conf\log4j.xml" ..\simulationengine.jar"

Error: log4j:ERROR Could not parse url [file:..//conf//log4j.xml].
java.io.FileNotFoundException: ..\conf\log4j.xml (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) 
2

There are 2 best solutions below

0
On

java -jar ..\simulationengine.jar, put the log4j.xml file at the root of your classpath, e.g. in ..\simulationengine.jar and it will work fine.

0
On
  1. URLs cannot contain backslashes. Try forward slashes.
  2. The JAR file argument to -jar must follow the -jar option. Your command line is all mixed up.

    java -Dlog4j.comfiguration=... -jar xxx.jar