10 private static BufferedReader
stdIn;
11 private static int pid = 0;
20 private static final String
serverClass =
"WhiteBoard.WbServerImpl";
21 private static final String
clientClass =
"WhiteBoard.WbClientImpl";
22 private static final String
linesClass =
"WhiteBoard.LinesFrameImpl";
31 public static void myPrint(String who, String what) {
33 System.out.println(who +
": " + what);
39 stdIn =
new BufferedReader(
new InputStreamReader(System.in));
43 System.out.print(msg +
": ");
46 }
catch (Exception e) {e.printStackTrace();}
47 if (s == null || s ==
"") s =
"empty";
54 public static void javaVM(
char c, String args) {
56 String classNm =
classNames[c ==
'S'? 0 : c ==
'C' ? 1 : 2];
57 String cmd =
javaCmd +
" " + classNm +
" " +
pid +
" " + args;
60 Runtime r = Runtime.getRuntime();
63 Process p = r.exec(cmd);
65 }
catch(Exception e) {
66 System.out.println(
"Error executing r.exec(" + cmd +
")");
68 }
catch(Exception e) {
69 System.out.println(
"Runtime Error executing [" + cmd +
"]");
73 public static String
makeURL(
char c, String
id) {
77 public static Remote
lookup(String url) {
78 for (
int j = 0; j < 10; j++)
80 return Naming.lookup(url);
81 }
catch (Exception e) {
82 myPrint(
"Naming.lookup(", url +
") not found yet ...");
83 try {Thread.sleep(1000);}
84 catch (Exception x) {x.printStackTrace();}
89 public static void main(String[] args) {
90 Invoke.javaVM(
'S',
"");
static final String rmiRegistryPfx
static final String serverClass
static void myPrint(String who, String what)
static final String classNames[]
static Remote lookup(String url)
static String javaCmd
The following Srings isolate path related issues.
static String promptAndGet(String msg)
static void javaVM(char c, String args)
Invoke java on the given class in a separate process.
static final String linesClass
static void setJavaCmdPath(String s)
static BufferedReader stdIn
static String makeURL(char c, String id)
static final String clientClass
static void main(String[] args)