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