Log in

View Full Version : read projectx standard output


Ac3Dc3
9th March 2006, 10:03
Hi

I'm trying to read the standard output from ProjectX from a .Net application. ProjectX is a Java application and regular (c sharp)

Process p = new Process();
StreamWriter sw;
StreamReader sr;
StreamReader err;

ProcessStartInfo psI = new ProcessStartInfo("cmd");
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
p.StartInfo = psI;

p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err = p.StandardError;
doesn't seem to work. Does anyone know how I can capture this info without using executable wrappers? Or if you just have general advice about launching java apps from .Net.. : )

Ac3Dc3

Doom9
9th March 2006, 10:30
ProcessStartInfo psI = new ProcessStartInfo("cmd");Umm.. what's the purpose of this? Do you really need a commandprompt wrapper? And if so, it's cmd.exe and you need to specify a path. If there's a way to control projectx from the commandline, your launching application needs to be java.exe.. after all you launch ProjectX from the commanprompt via a line like "java.exe packagename.ProjectX argument1 argument2 argument2".. so java.exe including the full path goes as the application, and the rest as arguments for your PSI.

Ac3Dc3
9th March 2006, 16:25
sorry, the code was probably misleading - i just meant to give an example of running a process from .Net (cmd.exe :rolleyes: )

ohhh yeahh i should have gone back to basics and thought about what runs the jar executable.. im now capturing the output of java.exe and giving it the arguments

-jar [path to compiled projectX.jar] projextXargument1 etc

and projectX definately does have a cli, its short but sweet! thanks for helping out a java n00b

btw is there a way of quickly ascertaining the path to java.exe on a users system?

Doom9
9th March 2006, 18:13
System.Environment.EnvironmentVariable (or thereof.. I'm typing off my head), and the variable is called Java_Home or something like that (do a set, look for java and you shall find).