Board index » jbuilder » RunTime exec environment strings help

RunTime exec environment strings help


2004-06-15 03:27:47 AM
jbuilder3
I'm getting a strange problem with my environment and command line settings
when I try to execute an external application using the RunTime class.
Using the following code, I run a Windows app that I created. The Windows
app does nothing other then display the working path, the command line and
the environment variables.
public void runApp() {
try {
File workingDir = new File("C:/Program Files/Borland/Delphi
5/Projects/RtiExec");
String[] cmd = new String[3];
cmd[0] = "C:/Program Files/Borland/Delphi 5/Projects/RtiExec/RtiExec";
cmd[1] = "-multicastDiscoveryEndpoint";
cmd[2] = "224.77.1.2:18555";
String[] env = new String[3];
env[0] = "RTI_HOME=C:/Program Files/DMSO/RTI1.3NG-V4";
env[1] = "RTI_BUILD_TYPE=Win2000-VC6/DMSO";
env[2] = "RTI_RID_FILE=C:/Ttcp/VMSA/bin/RTI.rid";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd, env, workingDir);
try {
int exitVal = proc.waitFor();
}
catch (Throwable t) {
t.printStackTrace();
}
System.out.println("Process exitValue: " + proc.exitValue());
}
catch (IOException e1) {
System.err.println(e1);
}
}
What I see in the Windows app is...
---
Working Directory...
C:\Program Files\Borland\Delphi 5\Projects\RtiExec
Command Line...
-multicastDiscoveryEndpoint
Environment Variables...
RTI_BUILD_TYPE=Win2000-VC6/DMSO
---
The command line is missing the last parameter and whats even stranger is
that the first and third environment strings are missing. Only the second
environment variable one shows up! And yes, I've tested the Delphi app to
make sure it works properly.
Anyone have any thoughts?
Thanks
DaveH
 
 

Re:RunTime exec environment strings help

DaveH wrote:
Quote
I'm getting a strange problem with my environment and command line settings
when I try to execute an external application using the RunTime class.

Using the following code, I run a Windows app that I created. The Windows
app does nothing other then display the working path, the command line and
the environment variables.

public void runApp() {
try {
File workingDir = new File("C:/Program Files/Borland/Delphi
5/Projects/RtiExec");
String[] cmd = new String[3];
cmd[0] = "C:/Program Files/Borland/Delphi 5/Projects/RtiExec/RtiExec";
cmd[1] = "-multicastDiscoveryEndpoint";
cmd[2] = "224.77.1.2:18555";

String[] env = new String[3];
env[0] = "RTI_HOME=C:/Program Files/DMSO/RTI1.3NG-V4";
env[1] = "RTI_BUILD_TYPE=Win2000-VC6/DMSO";
env[2] = "RTI_RID_FILE=C:/Ttcp/VMSA/bin/RTI.rid";

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd, env, workingDir);

try {
int exitVal = proc.waitFor();
}
catch (Throwable t) {
t.printStackTrace();
}
System.out.println("Process exitValue: " + proc.exitValue());
}
catch (IOException e1) {
System.err.println(e1);
}
}


What I see in the Windows app is...

---
Working Directory...
C:\Program Files\Borland\Delphi 5\Projects\RtiExec

Command Line...
-multicastDiscoveryEndpoint

Environment Variables...
RTI_BUILD_TYPE=Win2000-VC6/DMSO
---

The command line is missing the last parameter and whats even stranger is
that the first and third environment strings are missing. Only the second
environment variable one shows up! And yes, I've tested the Delphi app to
make sure it works properly.

Anyone have any thoughts?

Thanks
DaveH



Yah. I hate spaces in commands and filenames. Try "escaping" all those
spaces using '\'.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html