Reputation: 187
I'm trying to compile some .java files in command prompt using "javac *.java -Xlint" and I must include log4j.jar somewhere in my java-jdk directory obviously, because I'm getting "package org.apache.log4j does not exist" error.
Where should I put the log4j.jar file?
Upvotes: 0
Views: 591
Reputation: 10310
Usually projects are built using some build tool like maven or ant.
But if you want to build it using javac
I would suggest you to create the next project structure:
YourCoolProject
├ src
| └ com
| └ companyname
| └ Main.java
├ lib
| └ log4j.jar
└ build
(you paccage will look like this com.companyname
).
Then you can compile your code using next command (you have to run console in YourCoolProject
folder):
javac -d ./build -classpath "lib/*" -sourcepath src src/com/companyname/Main.java
In this case everything you add into /lib
folder will be automatically included to classpath. Using this command your code will be compiled into /build
folder.
Upvotes: 1