-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathExecProject.java
More file actions
84 lines (71 loc) · 2.08 KB
/
Copy pathExecProject.java
File metadata and controls
84 lines (71 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package javaforce.utils;
import java.io.*;
import java.util.*;
import javaforce.*;
/** ExecProject
*
* @author pquiring
*/
public class ExecProject implements ShellProcessListener {
private BuildTools tools;
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("ExecProject : Runs project using java");
System.out.println(" Usage : ExecProject buildfile");
System.exit(1);
}
try {
new ExecProject().run(args[0]);
} catch (Exception e) {
JFLog.log(e);
}
}
public void run(String buildfile) throws Exception {
tools = new BuildTools();
if (!tools.loadXML(buildfile)) throw new Exception("error loading " + buildfile);
String app = tools.getProperty("app");
String cfg = tools.getProperty("cfg");
if (cfg.length() == 0) {
cfg = app + ".cfg";
}
String user_home = System.getProperty("user.home");
String exec = "jfexec";
if (JF.isWindows()) {
String apptype = tools.getProperty("apptype");
if (apptype == null) {
apptype = "window";
}
switch (apptype) {
// case "window": exec += "w"; break; //for debugging purposes do not use 'w' version
}
}
Properties props = new Properties();
FileInputStream fis = new FileInputStream(cfg);
props.load(fis);
fis.close();
String classpath = props.getProperty("CLASSPATH");
String mainclass = props.getProperty("MAINCLASS");
String service = props.getProperty("SERVICE");
if (service != null) {
exec += "s";
}
if (JF.isWindows()) {
exec += ".exe";
}
ShellProcess sp = new ShellProcess();
sp.addListener(this);
ArrayList<String> cmd = new ArrayList<String>();
cmd.add(user_home + File.separator + "bin" + File.separator + exec);
cmd.add("-cp");
if (JF.isWindows()) {
cmd.add(classpath);
} else {
cmd.add(classpath.replaceAll("[;]", ":"));
}
cmd.add(mainclass);
sp.run(cmd.toArray(JF.StringArrayType), true);
}
public void shellProcessOutput(String str) {
System.out.print(str);
}
}