EvA2 cannot be launched using Java Web Start in its current version.

This commit is contained in:
Andreas Dräger 2012-02-21 17:39:26 +00:00
parent 7d281e2bf0
commit a9c0f3a4cf

View File

@ -840,7 +840,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @return * @return
*/ */
public boolean isOptRunning() { public boolean isOptRunning() {
if (currentModuleAdapter != null && (currentModuleAdapter instanceof AbstractModuleAdapter)) { if ((currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter)) {
return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning(); return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
} else return false; } else return false;
} }
@ -856,13 +856,19 @@ public class EvAClient implements RemoteStateListener, Serializable {
EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage()); EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage());
} }
if (newModuleAdapter == null) { if (newModuleAdapter == null) {
URL baseDir = this.getClass().getClassLoader().getResource(""); // When launching a Java Web Start application, baseDir will always be null!
URL baseDir = getClass().getClassLoader().getResource("");
String cp = System.getProperty("java.class.path","."); String cp = System.getProperty("java.class.path",".");
if (!cp.contains(baseDir.getPath())) { String dir = (baseDir == null) ? System.getProperty("user.dir") : baseDir.getPath();
// System.err.println("Working dir: " + dir);
if (baseDir == null) {
throw new RuntimeException("Cannot launch EvA2 due to an access restriction. If you are using Java Web Start, please download the application and try again.");
}
if (!cp.contains(dir)) {
// this was added due to matlab not adding base dir to base path... // this was added due to matlab not adding base dir to base path...
System.err.println("classpath does not contain base directory!"); System.err.println("classpath does not contain base directory!");
System.err.println("adding base dir and trying again..."); System.err.println("adding base dir and trying again...");
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + baseDir.getPath()); System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir);
ReflectPackage.resetDynCP(); ReflectPackage.resetDynCP();
m_ComAdapter.updateLocalMainAdapter(); m_ComAdapter.updateLocalMainAdapter();
loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care! loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!