37
37
38
38
import com .sun .jna .Native ;
39
39
import com .sun .jna .Pointer ;
40
+ import com .sun .jna .platform .win32 .Shell32 ;
40
41
import com .sun .jna .win32 .StdCallLibrary ;
41
42
import com .sun .jna .win32 .W32APIOptions ;
42
43
@@ -129,11 +130,15 @@ public void openURL(String url) throws Exception {
129
130
if (file .exists ()) {
130
131
// in this case convert the path to a "file:" url
131
132
url = file .toURI ().toString ();
132
-
133
- // this allows to open the file on Windows 10 that
134
- // has a more strict permission policy for cmd.exe
135
133
}
136
134
}
135
+ if (url .startsWith ("http" ) || url .startsWith ("file:" )) {
136
+ // this allows to open the file on Windows 10 that
137
+ // has a more strict permission policy for cmd.exe
138
+ final int SW_SHOW = 5 ;
139
+ Shell32 .INSTANCE .ShellExecute (null , null , url , null , null , SW_SHOW );
140
+ return ;
141
+ }
137
142
138
143
// this is not guaranteed to work, because who knows if the
139
144
// path will always be c:\progra~1 et al. also if the user has
@@ -150,18 +155,12 @@ public void openURL(String url) throws Exception {
150
155
// "Access is denied" in both cygwin and the "dos" prompt.
151
156
//Runtime.getRuntime().exec("cmd /c " + currentDir + "\\reference\\" +
152
157
// referenceFile + ".html");
153
- if (url .startsWith ("http" ) || url .startsWith ("file:" )) {
154
- // open dos prompt, give it 'start' command, which will
155
- // open the url properly. start by itself won't work since
156
- // it appears to need cmd
157
- Runtime .getRuntime ().exec ("cmd /c start \" \" \" " + url + "\" " );
158
- } else {
159
- // just launching the .html file via the shell works
160
- // but make sure to chmod +x the .html files first
161
- // also place quotes around it in case there's a space
162
- // in the user.dir part of the url
163
- Runtime .getRuntime ().exec ("cmd /c \" " + url + "\" " );
164
- }
158
+
159
+ // just launching the .html file via the shell works
160
+ // but make sure to chmod +x the .html files first
161
+ // also place quotes around it in case there's a space
162
+ // in the user.dir part of the url
163
+ Runtime .getRuntime ().exec ("cmd /c \" " + url + "\" " );
165
164
}
166
165
167
166
0 commit comments