ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/PlatformTools/src/net/oni2/platformtools/applicationinvoker/Java.java
Revision: 724
Committed: Thu Mar 21 11:43:42 2013 UTC (12 years, 7 months ago) by alloc
Content type: text/x-java
File size: 906 byte(s)
Log Message:
Platform tools library (information about platform, program execution)

File Contents

# Content
1 package net.oni2.platformtools.applicationinvoker;
2
3 import java.io.File;
4
5 import net.oni2.platformtools.PlatformInformation;
6 import net.oni2.platformtools.PlatformInformation.Platform;
7
8 /**
9 * @author Christian Illy
10 */
11 public class Java {
12 private static int isFound = -1;
13 private static File jre = null;
14
15 /**
16 * @return Was a JRE found
17 */
18 public static boolean isInstalled() {
19 if (isFound < 0) {
20 getRuntimeExe();
21 }
22 return isFound == 1;
23 }
24
25 /**
26 * @return The JRE executable
27 */
28 public static File getRuntimeExe() {
29 if (isFound < 0) {
30 File jrehome = new File(System.getProperties().getProperty(
31 "java.home"), "bin");
32 if (PlatformInformation.getPlatform() == Platform.WIN)
33 jre = new File(jrehome, "javaw.exe");
34 else
35 jre = new File(jrehome, "java");
36 if (!jre.exists()) {
37 isFound = 0;
38 jre = null;
39 } else {
40 isFound = 1;
41 }
42 }
43 return jre;
44 }
45 }