Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Runtime.exec() with env and working directory parameters is not wor

  Asked By: Hondo    Date: May 07    Category: Java    Views: 2275
  

I have a problem with Runtime.exec command when I want to execute it
in the working directory.
My Runtime.exec command calls an external Application(Samcef) which
uses certain environment variables
and licence for calling the external application.

I have used this command:-
............
............

String[] sz_env = {""};
String sz_working_directory = D:\\users
String sz_execute_cmd = sz_Samcef_exe + " ba,as iteration n 1 <
samcef_input.dat";

Process wait = Runtime.getRuntime().exec(sz_exec_command, sz_env, new
File(sz_working_directory));
............
............

It does'nt take the existing environment settings of the operating
system.

But if I use this command from command prompt it works fine.
If I use cmd /c ,go to the working directory using cd then it works
fine.
But I dont want to use cmd/c , I want it to work both on windows and
unix.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Dustin Dean     Answered On: May 07

Actually you have to set the windows  environment
set it and refresh the windows.
for this set the environment  variable in Autoexec.bat
and run it through start menu
refresh the windows for any

 




Tagged: