-
Notifications
You must be signed in to change notification settings - Fork 2
/
javaOpen.groovy
executable file
·49 lines (42 loc) · 1.33 KB
/
javaOpen.groovy
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
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/env groovy
import java.awt.Desktop;
String path = '/home/pasha/temp/test.xls';
File f = new File (path);
try {
if(Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(f);
return;
}
} catch(Exception e) {
log.err(e);
}
try {
String cmd = "/usr/bin/xdg-open";
if(new File(cmd).exists()) {
// Runtime.getRuntime().exec(new String[] { cmd, path });
Runtime.getRuntime().exec( (String[])[cmd, path] );
return;
}
} catch(Exception e) {
log.err(e);
}
try {
String cmd = "/usr/bin/gnome-open";
if(new File(cmd).exists()) {
// Runtime.getRuntime().exec(new String[] { cmd, path });
Runtime.getRuntime().exec( (String[])[cmd, path] );
return;
}
} catch(Exception e) {
log.err(e);
}
try {
String cmd = "/usr/bin/kde-open";
if(new File(cmd).exists()) {
// Runtime.getRuntime().exec(new String[] { cmd, path });
Runtime.getRuntime().exec( (String[])[cmd, path] );
return;
}
} catch(Exception e) {
log.err(e);
}