diff --git a/java/net/i2p/router/WinUpdateProcess.java b/java/net/i2p/router/WinUpdateProcess.java index 3456609..df52c76 100644 --- a/java/net/i2p/router/WinUpdateProcess.java +++ b/java/net/i2p/router/WinUpdateProcess.java @@ -1,6 +1,7 @@ package net.i2p.router; import java.io.*; +import java.util.Map; import java.util.function.*; import net.i2p.I2PAppContext; import net.i2p.router.*; @@ -43,15 +44,15 @@ class WinUpdateProcess implements Runnable { if (file == null) return; - var workingDir = workDir(); - var logFile = new File(workingDir, "log-" + version + ".txt"); + File workingDir = workDir(); + File logFile = new File(workingDir, "log-" + version + ".txt"); if (logFile.canWrite()) { // check if we can write to the log file. If we can, use the // ProcessBuilder to run the installer. ProcessBuilder pb = new ProcessBuilder( file.getAbsolutePath(), "/S", "/D=" + workingDir.getAbsolutePath()); - var env = pb.environment(); + Map env = pb.environment(); env.put("OLD_I2P_VERSION", version); env.remove("RESTART_I2P"); diff --git a/java/net/i2p/router/WindowsServiceUtil.java b/java/net/i2p/router/WindowsServiceUtil.java index a1191a7..511c3fe 100644 --- a/java/net/i2p/router/WindowsServiceUtil.java +++ b/java/net/i2p/router/WindowsServiceUtil.java @@ -29,7 +29,7 @@ import java.io.InputStreamReader; public class WindowsServiceUtil { public WindowsServiceUtil() {} - private String queryService(String serviceName) { + public static String queryService(String serviceName) { String result = ""; String line; ProcessBuilder pb = new ProcessBuilder("sc", "query", serviceName); @@ -43,13 +43,16 @@ public class WindowsServiceUtil { result += line; } } catch (InterruptedException e) { + System.err.println(e.toString()); } catch (IOException e) { + System.err.println(e.toString()); } } catch (IOException e) { + System.err.println(e.toString()); } return result; } - private String getStatePrefix(String qResult) { + public static String getStatePrefix(String qResult) { String statePrefix = "STATE : "; // get the first occurrence of "STATE", then find the // next occurrence of of ":" after that. Count the @@ -66,7 +69,7 @@ public class WindowsServiceUtil { } return statePrefix; } - public String getServiceState(String serviceName) { + public static String getServiceState(String serviceName) { // String statePrefix = "STATE : "; String qResult = queryService(serviceName); String statePrefix = getStatePrefix(qResult); @@ -95,4 +98,8 @@ public class WindowsServiceUtil { } return stateString; } + static void main(String args[]) { + String state = getServiceState("i2p"); + System.out.println("state: " + state); + } }