forked from docusign/code-examples-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
37 lines (31 loc) · 1.44 KB
/
Copy pathApp.java
File metadata and controls
37 lines (31 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.docusign;
import java.io.IOException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
@SpringBootApplication(exclude={JmxAutoConfiguration.class})
public class App {
public static void main(String[] args) throws IOException {
SpringApplication.run(App.class, args);
openHomePage();
}
private static void openHomePage() throws IOException {
// Each operating system opens web browsers differently so we need to determine the user's
// OS and open a browser to the example homepage accordingly.
Runtime rt = Runtime.getRuntime();
if (OSDetector.isMac()){
String[] arguments = { "osascript", "-e", "open location \"" + "http://localhost:8080" + "\"" };
rt.exec(arguments);
}
else if (OSDetector.isWindows()){
rt.exec("rundll32 url.dll,FileProtocolHandler " + "http://localhost:8080");
}
else if (OSDetector.isLinux()){
String [] browsers = {"firefox", "safari", "chrome", "mozilla"};
StringBuffer cmd = new StringBuffer();
for (int i=0; i<browsers.length; i++)
cmd.append( (i==0 ? "" : " || " ) + browsers[i] +" \"" + "http://localhost:8080" + "\" ");
rt.exec(new String[] { "sh", "-c", cmd.toString() });
}
}
}