1 |
package net.oni2.aeinstaller.backend; |
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Vector; |
5 |
|
6 |
import net.oni2.aeinstaller.backend.Settings.Platform; |
7 |
import net.oni2.aeinstaller.backend.packages.Package; |
8 |
|
9 |
/** |
10 |
* @author Christian Illy |
11 |
*/ |
12 |
public class ToolLauncher { |
13 |
/** |
14 |
* @param p |
15 |
* Package of tool to launch |
16 |
* @throws Exception |
17 |
* If a required runtime is not found |
18 |
*/ |
19 |
public static void launch(Package p) throws Exception { |
20 |
File exe = p.getExeFile(); |
21 |
|
22 |
Vector<String> params = new Vector<String>(); |
23 |
switch (p.getExeType()) { |
24 |
case OSBINARY: |
25 |
break; |
26 |
case DOTNET: |
27 |
if (!DotNet.isInstalled()) |
28 |
throw new Exception(".NET not found"); |
29 |
if (Settings.getPlatform() != Platform.WIN) { |
30 |
params.add(DotNet.getRuntimeExe()); |
31 |
} |
32 |
break; |
33 |
case JAR: |
34 |
File jre = null; |
35 |
if (Settings.getPlatform() == Platform.WIN) |
36 |
jre = new File(System.getProperties().getProperty( |
37 |
"java.home"), "bin/javaw.exe"); |
38 |
else |
39 |
jre = new File(System.getProperties().getProperty( |
40 |
"java.home"), "bin/java"); |
41 |
if (!jre.exists()) |
42 |
throw new Exception("JRE not found"); |
43 |
params.add(jre.getPath()); |
44 |
params.add("-jar"); |
45 |
break; |
46 |
} |
47 |
params.add(exe.getPath()); |
48 |
|
49 |
File wd = p.getWorkingDir(); |
50 |
|
51 |
AppExecution.execute(params, wd); |
52 |
} |
53 |
} |