I have the app, which i launch with "Java Web Start". This app is used for launching other java apps. The issue is that with the command "java -cp class_path class_name" java app cannot be launched, an exception "Could not find or load main class class_name" appears.
However, Class.forName(class_name) doesn't throw exception: "ClassNotFoundException" and i can run static method from another jar(but it's in current JVM).
Without using "Java Web Start" everything is alright.
When I launch the common app, I use the command: java -cp *; com.vitaxa.voidbox.MainApp. In this way I form the classpath, collecting everything from the current directory.
Then I can launch other apps, using the command: java -cp current_classpath class_name. So everything works well, but without using Java WebStart.
There is the difference. For getting the classPath I use the next method:
private static String getClasspath() {
final StringBuilder sb = new StringBuilder();
ClassLoader classLoader = TaskRunner.class.getClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
final URL[] urls = ((URLClassLoader) classLoader).getURLs();
for (URL url : urls) {
sb.append(url.getFile()).append(";");
}
return sb.toString();
}
In case of running with an ordinary app, the classpath is: /D:/WorkDir/Applications/FirstApp.jar;/D:/WorkDir/Applications/SecondApp.jar;/D:/WorkDir/Applications/ThirdApp.jar;
and running with using Java WebStart the classpath is: /Applications/FirstApp.jar;/Applications/SecondApp.jar;/Applications/ThirdApp.jar.
P.S. I tried using System.getProperty("java.class.path"), it hadn't helped.