Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] starting SWT client from a different java process



Hi,

This is a follow-up to my previous off-topic question on getting an SWT
client to work with EJBs. I've narrowed down my problem to the extent that
it has NOTHING to do with J2EE.  The same problem occurs in other SWT
clients that I tried calling in this way.

Basically, I just need to start my client with a huge classpath, which is
longer than 256 characters and hence cannot be passed to java.exe.
Therefore, I've written a simple program that just executes the java.exe
call using Runtime.exec(). Once again, I can run my Runner.class from WSAD
and it calls my SWT client alright, and everything works great. However,
when I do "java Runner" from the command line, it simply exits, and the SWT
client is not spawned! If I add a Process.waitFor() call in the end, it
simply hangs. What am I doing wrong? By the way, the same exact problem
occurs to an swtexample file FileViewer (which doesn't use an J2EE), so the
problem is not in the way I wrote the client, it's with calling it.

I am running out of ideas here.. Please help! :( The source of my little
program follows:

public class Runner {

      public static void main(String[] args) {
            String execString = "java.exe -classpath "+ "very long
classpath string"+ " DocumentViewer";

            byte[] b = new byte[700];
            byte[] c = new byte[700];
            try {
                  System.out.println(execString2);
                  Process p = Runtime.getRuntime().exec(execString2);
                  p.getOutputStream().close();

//                p.getInputStream().read(b);
//                p.getErrorStream().read(c);
//                String myString = new String(b);
//                String errString = new String(c);
//                System.out.println("Output: "+myString);
//                System.out.println("Process Error: "+errString);
                  p.getInputStream().close();
//                p.waitFor();
            } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println(e.getMessage());
            }
      }
}

As you can see I am closing all the input/output streams. Incidentally, I
also close System.out stream in the main() of my SWT client, just in case.
Any ideas?

Alex



Back to the top