There have been a couple of NSTask
related questions, but after paging through them I still have no idea what to do.
I'm writing a frontend for a java server in Cocoa, launched by java -Xmx1024M -Xms1024M -jar server.jar nogui
(I've left out the nogui
arg in my current code so as not to fill up my computer with unnecessary orphaned instances of server).
My current code correctly runs the .jar file; now I need a way to capture (and parse) output and send input to the process.
server = [[NSTask alloc] init];
pipe = [NSPipe pipe];
NSArray *args = [NSArray arrayWithObjects:@"-Xms1024M",
@"-Xmx1024M",
@"-jar",
@"server.jar",
nil];
[server setLaunchPath:@"/usr/bin/java"];
[server setCurrentDirectoryPath:@"MyApp.app/Contents/Resources/"];
[server setArguments:args];
[server setStandardOutput:pipe];
[server setStandardInput:pipe];
[server launch];
I've read up on NSPipe
and NSTask
and everything, but I can't seem an answer geared towards my problem:
- Live, parsed (RegEx?) output to
NSTextView
orNSTableView
. - Input from
NSTextField
EDIT: Or should I use launchd
? How would I do that?