-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCLoaderRun.java
46 lines (33 loc) · 1.41 KB
/
CLoaderRun.java
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
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Objects;
/**
* Created by eagle on 13.09.2014.
*/
public class CLoaderRun {
public static File checkedfile;
private static long timeStamp;
private static boolean isFileUpdated(File cfile){
if (timeStamp != cfile.lastModified()) {
System.out.println("Last updated:" + new Date(timeStamp) + "!\nNow:" + new Date(checkedfile.lastModified()));
timeStamp = cfile.lastModified();
return true;
}
return false;
}
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, InterruptedException {
checkedfile = new File("./src/TestModule.java");
while (true) {
if (isFileUpdated(checkedfile)) {
try {
Runtime.getRuntime().exec("javac ./src/TestModule.java").waitFor();
} catch (InterruptedException e) {
System.out.println("Error was found :(" + e);
}
// Object j = new ClassLoad().loadClass("TestModule",false).newInstance();
Object t = new CLoader(new File("./src"), CLoaderRun.class.getClassLoader()).findClass("TestModule").newInstance();
System.out.println(t);
}
}
}}