source: AE/installer2/src/net/oni2/aeinstaller/backend/DotNet.java@ 718

Last change on this file since 718 was 709, checked in by alloc, 12 years ago

AEI2: Refactorings for breaking out independent features into libraries

File size: 2.0 KB
RevLine 
[672]1package net.oni2.aeinstaller.backend;
2
3import java.io.IOException;
4import java.lang.reflect.InvocationTargetException;
5import java.util.Map;
6import java.util.Vector;
7
[709]8import net.oni2.applicationinvoker.AppExecution;
9import net.oni2.applicationinvoker.AppExecutionResult;
10import net.oni2.settingsmanager.Settings;
11import net.oni2.settingsmanager.Settings.Architecture;
12import net.oni2.settingsmanager.Settings.Platform;
[672]13
14/**
15 * @author Christian Illy
16 */
17public class DotNet {
18
19 /**
20 * @return is a .NET implementation installed?
21 */
22 public static boolean isInstalled() {
23 switch (Settings.getPlatform()) {
24 case WIN:
25 try {
26 int view = WinRegistry.KEY_WOW64_32KEY;
27 if (Settings.getArchitecture() == Architecture.AMD64)
28 view = WinRegistry.KEY_WOW64_64KEY;
29
30 Map<String, String> m = WinRegistry
31 .readStringValues(
32 WinRegistry.HKEY_LOCAL_MACHINE,
33 "Software\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727",
34 view);
35 return m != null;
36 } catch (IllegalArgumentException e) {
37 e.printStackTrace();
38 } catch (IllegalAccessException e) {
39 e.printStackTrace();
40 } catch (InvocationTargetException e) {
41 e.printStackTrace();
42 } catch (Exception e) {
43 if (!e.getMessage()
44 .equals("Registry access not supported (not a Windows OS?)."))
45 e.printStackTrace();
46 }
47 return false;
48 case MACOS:
49 case LINUX:
50 Vector<String> cmd = new Vector<String>();
51 cmd.add("which");
52 cmd.add("mono");
[702]53 AppExecutionResult res = null;
[672]54 try {
55 res = AppExecution.executeAndWait(cmd);
56 } catch (IOException e) {
57 e.printStackTrace();
58 }
59 if (res != null) {
[702]60 if (res.output.get(0).startsWith("/")
61 && res.output.get(0).endsWith("mono")) {
[672]62 return true;
63 }
64 }
65 return false;
66 default:
67 return false;
68 }
69 }
70
71 /**
72 * @return Get the .Net runtime executable name
73 */
74 public static String getRuntimeExe() {
75 if (Settings.getPlatform() != Platform.WIN)
76 return "mono";
77 return "";
78 }
79
80}
Note: See TracBrowser for help on using the repository browser.