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