diff --git a/main/src/main/java/sd/dashboard/SimulationProcessManager.java b/main/src/main/java/sd/dashboard/SimulationProcessManager.java index a1818f3..0658b2b 100644 --- a/main/src/main/java/sd/dashboard/SimulationProcessManager.java +++ b/main/src/main/java/sd/dashboard/SimulationProcessManager.java @@ -95,18 +95,24 @@ public class SimulationProcessManager { builder = new ProcessBuilder(javaBin, "-cp", classpath, className); } - // this is a linux thing - not sure about windows + // get the OS temp folder + // Linux: /tmp/ + // Windows: %AppData%\Local\Temp\ + String tempDir = System.getProperty("java.io.tmpdir"); + String logName = className.substring(className.lastIndexOf('.') + 1) + (arg != null ? "-" + arg : "") + ".log"; - File logFile = new File("/tmp/" + logName); + + // use the (File parent, String child) constructor to handle slash/backslash + // automatically + File logFile = new File(tempDir, logName); + builder.redirectOutput(logFile); builder.redirectError(logFile); Process process = builder.start(); runningProcesses.add(process); System.out.println("Started " + className + (arg != null ? " " + arg : "")); - } - - public boolean isSimulationRunning() { - return !runningProcesses.isEmpty() && runningProcesses.stream().anyMatch(Process::isAlive); + // print where the logs are actually going + System.out.println("Logs redirected to: " + logFile.getAbsolutePath()); } }