-
Notifications
You must be signed in to change notification settings - Fork 0
/
njava.java
56 lines (51 loc) · 1.11 KB
/
njava.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
47
48
49
50
51
52
53
54
55
56
/*
* This software is Public Domain.
*/
import maximum.jvm.VM;
import maximum.jvm.ProcessListener;
/**
* Command line harness to run jjvm like java.exe.
*
* Remember, System.out writes to a buffer which is
* passed to processComplete. System.err is passed to
* processError.
*
* The process ID passed to exec is used to identify
* the terminating thread in the process* callbacks.
*/
public class njava implements ProcessListener
{
public static void main(String[] args)
{
if ( args.length == 0 )
{
System.out.println("USAGE: java [-test | my.package.className]");
return;
}
if (args[0].equals("-test"))
{
args[0] = "maximum.test.Test";
}
new njava(args[0]);
}
public njava(String cls)
{
try
{
VM vm = new VM();
vm.exec ( 0, cls, this );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
public void processComplete ( int processId, String output )
{
System.out.println(output);
}
public void processError ( int processId, String errorOutput )
{
System.out.println(errorOutput);
}
}