JAL-3321 Corrected the badly configured getdown-launcher.jar for updating and updated...
[jalview.git] / getdown / src / getdown / launcher / src / main / java / com / threerings / getdown / launcher / Getdown.java
index 5750fce..d82ed15 100644 (file)
@@ -499,6 +499,19 @@ public abstract class Getdown extends Thread
             throw new IOException("m.java_download_failed");
         }
 
+        // on Windows, if the local JVM is in use, we will not be able to replace it with an
+        // updated JVM; we detect this by attempting to rename the java.dll to its same name, which
+        // will fail on Windows for in use files; hackery!
+        File javaLocalDir = new File(_app.getAppDir(), LaunchUtil.LOCAL_JAVA_DIR+File.separator);
+        File javaDll = new File(javaLocalDir, "bin" + File.separator + "java.dll");
+        if (javaDll.exists()) {
+            if (!javaDll.renameTo(javaDll)) {
+                log.info("Cannot update local Java VM as it is in use.");
+                return;
+            }
+            log.info("Can update local Java VM as it is not in use.");
+        }
+
         reportTrackingEvent("jvm_start", -1);
 
         updateStatus("m.downloading_java");