public void run(String arg) { if (arg.equals("menus")) { updateMenus(); return; } if (IJ.getApplet() != null) return; URL url = getClass().getResource("/ij/IJ.class"); String ij_jar = url == null ? null : url.toString().replaceAll("%20", " "); if (ij_jar == null || !ij_jar.startsWith("jar:file:")) { error("Could not determine location of ij.jar"); return; } int exclamation = ij_jar.indexOf('!'); ij_jar = ij_jar.substring(9, exclamation); if (IJ.debugMode) IJ.log("Updater (jar loc): " + ij_jar); File file = new File(ij_jar); if (!file.exists()) { error("File not found: " + file.getPath()); return; } if (!file.canWrite()) { String msg = "No write access: " + file.getPath(); error(msg); return; } String[] list = openUrlAsList(IJ.URL + "/download/jars/list.txt"); int count = list.length + 3; String[] versions = new String[count]; String[] urls = new String[count]; String uv = getUpgradeVersion(); if (uv == null) return; versions[0] = "v" + uv; urls[0] = IJ.URL + "/upgrade/ij.jar"; if (versions[0] == null) return; for (int i = 1; i < count - 2; i++) { String version = list[i - 1]; versions[i] = version.substring(0, version.length() - 1); // remove letter urls[i] = IJ.URL + "/download/jars/ij" + version.substring(1, 2) + version.substring(3, 6) + ".jar"; } versions[count - 2] = "daily build"; urls[count - 2] = IJ.URL + "/ij.jar"; versions[count - 1] = "previous"; urls[count - 1] = IJ.URL + "/upgrade/ij2.jar"; int choice = showDialog(versions); if (choice == -1 || !Commands.closeAll()) return; // System.out.println("choice: "+choice); // for (int i=0; i<urls.length; i++) System.out.println(" "+i+" "+urls[i]); byte[] jar = null; if ("daily build".equals(versions[choice]) && notes != null && notes.contains(" </title>")) jar = getJar("http://wsr.imagej.net/download/daily-build/ij.jar"); if (jar == null) jar = getJar(urls[choice]); if (jar == null) { error("Unable to download ij.jar from " + urls[choice]); return; } Prefs.savePreferences(); // System.out.println("saveJar: "+file); saveJar(file, jar); if (choice < count - 2) // force macro Function Finder to download fresh list new File(IJ.getDirectory("macros") + "functions.html").delete(); System.exit(0); }