Java Service Wrapper is the tools I need to run as a Windows service but came into a problem with java.lang.ClassNotFoundException
My default command line is: java -jar software.jar
I have update the wrapper.conf for running software.jar located in D:\ and there was an error, the changes I have made:
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=../software.jar
wrapper.java.classpath.2=../lib/wrapper.jar
and what should I put for this parameter? If I comment out, it would use Main class
wrapper.java.mainclass=software
As I declare “software” as the main class, I got the dread error:
wrapper | Launching a JVM...
jvm 1 | java.lang.NoClassDefFoundError: org/xsocket/connection/IHandler
jvm 1 | Caused by: java.lang.ClassNotFoundException: org.xsocket.connection.I
Handler
jvm 1 | at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
jvm 1 | at java.security.AccessController.doPrivileged(Native Method)
jvm 1 | at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
jvm 1 | at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
jvm 1 | Could not find the main class: xSocketServer. Program will exit.
wrapper | JVM exited while loading the application.
jvm 1 | Exception in thread "main"
wrapper | CTRL-C trapped. Shutting down.
wrapper | <-- Wrapper Stopped
My software.jar contains:
META-INF
org -- Eclipse setting
software.class
xsoftwareHandler.class
xSocket.jar
What I suggest is to store all libraries in your
lib/directory and then add the following information in yourwrapper.conffile:This way, the
Java Service Wrapperwill load all the*.jarfile located in../lib/directory in the classpath, and you should not get this error again.Of course, you can also define each JAR individually if you prefer: