0

I need to set up log4j so that I can run a java Driver class (with main method) from command prompt with java command.

In order to do so, I need to first set Log4J. To do so, I ran the command as

D:\java\bin>java -Dlog4j.configurationFile=file:"D:\log4j.properties" - jar D:\tomcat\webapps\WEB-INF\lib\log4j-1.2.17.jar

But I get an error as: no main manifest attribute, in D:\tomcat\webapps\WEB-INF\lib\l og4j-1.2.17.jar

What am I doing wrong?

Sam G
  • 1
  • 1
  • Does this help ? https://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute – Harmandeep Singh Kalsi Jun 21 '20 at 04:22
  • shouldn't you add a Driver class? Like this: java -Dlog4j.configurationFile=file:"D:\log4j.properties" - jar D:\tomcat\webapps\WEB-INF\lib\log4j-1.2.17.jar Driver – AminM Jun 21 '20 at 04:40
  • What do you exactly mean by adding the word Driver? If I add the word Driver as is, I get an error as "cannot create a Virtual machine". Did you mean, adding the driver class? I tried something as below, but get the same error of (cannot create Virtual Machine): D:\java\bin> java -Dlog4j.configurationFile=file:"D:\log4j.properties" - jar D:\mylib\log4j-1.2.17.jar -classpath D:\mycode\myjar.jar org.mycode.MyDriver – Sam G Jun 21 '20 at 05:01
  • use like this `java -Dlog4j.configurationFile=file:"D:\log4j.properties" -classpath D:\mylib\log4j-1.2.17.jar D:\mycode\myjar.jar org.mycode.MyDriver` – Pandey Amit Jun 21 '20 at 08:15

0 Answers0