Quantcast
Channel: Running interactive shell program in Java - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by David Williams for Running interactive shell program in Java

$
0
0

Well, first, ProcessBuilder is in Java 6 too. If you mean that version in inadequate, or something, then I think there are two pieces of information you need to know. First, the main way of running an "exernal editor" would likely be to use the Runtime class and exec method. I suspect thats what you are doing already? Second, your current GUI, at some level, has an "event loop" which is a simple, but main, thread, that does nothing but "waits for an event" (such as keypress or "window event"), dispatches that event to interested listeners, and then waits for the next event. Keypresses and events to the external editor, would not be coming through this event loop ... well, not easily, anyway, without using something much more elaborate, like OLE APIs. But, it is that "event loop" that keeps Java alive and interactive while other things also go on, such as editing in an external editor. I'm not sure what GUI framework you are using, but most would already have such a loop and you shouldn't have to worry about it. If you are saying that in this command line mode you want, you do NOT want your normal GUI running, then you basically have to duplicae the "event loop" that is has, and start that thread first, and then call the runtime.exec method. Make sense?

FWIW, if you don't "have source" to see the GUI framework you are currently using, if you wanted to see one, just for learning more about event loops, Eclipse SWT has one in it's "Display" class and some examples that might be similar to what you want to do. (Note, SWT can be run "stand alone" without the rest of Eclipse, in case you were wondering).

HTH


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>