Skip to content

Commit

Permalink
feat: open browser automatically when ready in standalone mode
Browse files Browse the repository at this point in the history
  • Loading branch information
D-D-H committed Nov 13, 2023
1 parent 3677aca commit 7370ec2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/src/main/java/org/eclipse/jifa/server/ReadyListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.jifa.server;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SystemUtils;
import org.eclipse.jifa.server.enums.FileType;
import org.eclipse.jifa.server.enums.Role;
import org.eclipse.jifa.server.service.AnalysisApiService;
Expand Down Expand Up @@ -66,6 +67,21 @@ public void fireReadyEvent() {
}
}
}

openBrowser("http://localhost:" + config.getPort());
}
}

private void openBrowser(String url) {
try {
if (SystemUtils.IS_OS_WINDOWS) {
Runtime.getRuntime().exec("cmd /c start " + url);
} else if (SystemUtils.IS_OS_MAC) {
Runtime.getRuntime().exec("/usr/bin/open " + url);
}
} catch (IOException e) {
// ignored
e.printStackTrace();
}
}
}

0 comments on commit 7370ec2

Please sign in to comment.