I have problem with running my java project.
E:\Workspace\compiled>java -classpath server\libraries\log4j-1.2.16.jar;E:\Workspace\compiled\server\service-1.0-SNAPSHOT.jar;E:\Workspace\compiled\server\libraries\log4j-1.2.16.jar -Djava.security.policy=E:\Workspace\compiled\socket.policy -Djava.rmi.server.codebase=file:///E:\Workspace\compiled\server\service-1.0-SNAPSHOT.jar -jar E:\Workspace\compiled\server\service-1.0-SNAPSHOT.jar E:\Workspace\compiled\log4j.properties
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
at pwr.mgr.server.service.Launcher.main(Launcher.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
It's compiled using maven and I end up with .jar file. I decided today, that I'll use log4j for logging instead of wimple System.out... Before this change it was working fine
here's how I run it
java -cp .;%SRV_ADDR%;%SRV_LIBS% -Djava.security.policy=%POLICY_FILE% -Djava.rmi.server.codebase=file:///%SRV_ADDR% pwr.mgr.server.service.Launcher %CD%\log4j.properties
SRV_ADDR points to my service.jar (with Launcher class)
SRV_LIBS points to log4j-1.2.16.jar
I added ".;" at the begining hoping it would help, because mentioned files are in child directory to the one from I am trying to launch this.
I should also mention that I need to haev log4j library somewhere here, because I will be moving my app onto another machine and I don't know what libraries to expect there, maybe only pure java, so I need to deliver everything in one package.
If anyone is interested in Launcher class it's very simple:
public class Launcher {
public static void main(String args[]) {
PropertyConfigurator.configure(args[0]);
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
Runtime.getRuntime().exec("rmiregistry");
ServerIntf obj = new Server();
Registry registry = LocateRegistry.getRegistry();
registry.rebind("Server", obj);
System.out.println("Server bound in registry");
} catch (Exception e) {
System.out.println("Server err: " + e.getMessage());
e.printStackTrace();
}
}
}
Does anyone have any idea what am I doing wrong? Maybe adding only this one log4j jar file is not enough? I copied it from my maven repository.
EDIT1 already changed jar i'm pointing to from log4j-1.2.16-javadoc.jar to log4j-1.2.16.jar but it didn't help