I have a java application that is run using the following command:
java -cp .;lib\*;myapp.jar com.app.myapp.MyAppStart
The myapp.jar is in a folder that has the following files and structure
/demo
/lib
/conf
myapp.jar
myapp.bat
The myapp.bat contains the above run command so when you double click on it, it runs the program. Everything works fine if i copy the folder to a local path. For example if the folder is in
c:\program\myapps\demo i can just go in that folder and double click on the myapp.bat script and the program starts.
The problem i have now is i want to copy the demo folder to a path on the network. I tested it by copying it to \\London-server01\applications\client\demo\ but that raises the following exception
Exception in thread "main" java.lang.NoClassDefFoundError: com/app.myapp/MyAppStart
Caused by: java.lang.ClassNotFoundException: com.app.myapp.MyAppStart
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)
Could not find the main class: com.app.myapp.MyAppStart. Program will exit.
It looks like it doesnt like the fact that the program is run from a network drive. I tried a different approach by mapping \\London-server01\applications\client\demo\ to a local drive letter and that
works fine without any issues. It only fails to work if i use the full network path to access the folder. Is there any way i can get it to work without the need to map the network path?
Instead using . (for the current directory). Assign it to a variable and qualify the jar with the entire path to run it.
set MY_JAR_PATH=\London-server01\applications\client\demo\
java -cp %MY_JAR_PATH%;lib*;%MY_JAR_PATH%\myapp.jar com.app.myapp.MyAppStart
This might help!