Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running a .exe from JAVA on Linux

 
Elvie D'Souza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need help in running gdalinfo.exe on LINUX from a JAVA program.

I have all the environment variables set. When I use the following commands, I do not get any output.

List<String> cmds = new ArrayList<String>();
cmds.add("gdalinfo");
cmds.add(param1);
etc

Process proc = new ProcessBuilder(cmds).start();

However, when I open a terminal and run gdalinfo, it executes.

Please help

Thanks
Elvie
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Have you got spaces between the parameters in the command String? I presume using a List will insert the spaces in the correct places.
How are you emptying the Process' input and error streams?
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When Runtime.exec() won't.
 
Elvie D'Souza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code for emptying the streams:

InputStreamReader isr = new InputStreamReader(this.is);
BufferedReader br = new BufferedReader(isr);

String line = null;
while ((line = br.readLine()) != null) {
if (line.length() > 0)
this.sb.append(line).append("\n");
}

I have already gonr through the article "When Runtime.exec() won't" but it has not helped me.

The code runs fine on windows but fails on Linux. Why??

Thanks
Elvie
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elvie D'Souza wrote:
I need help in running gdalinfo.exe on LINUX from a JAVA program.

Exe? As in Windows executable? On Linux???
 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exe? As in Windows executable? On Linux???


Elvie is trying to say "gdalinfo" (exe)cutable. Thats quite clear... please dont go after the literal meaning when someone seek help

@Elvie
What is the error you are getting ? Can you give the stacktrace etc.
 
Stephan van Hulst
Bartender
Pie
Posts: 5893
63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not quite clear though. .exe is a Windows format, and he's stating he's trying to run it on Linux.
 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:It's not quite clear though. .exe is a Windows format, and he's stating he's trying to run it on Linux.


Executable word is not dedicated to any platform.... and there is a gdalinfo utility available for linux. So I thought its clear..
 
Stephan van Hulst
Bartender
Pie
Posts: 5893
63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry Prem, but we need to be nitpickers. If people don't use the proper names and terms for thing, we won't know if they are careful enough to use proper names when it matters. We may understand what he means, a computer doesn't.
 
Paul Clapham
Sheriff
Posts: 21124
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prem pillai wrote:
Stephan van Hulst wrote:It's not quite clear though. .exe is a Windows format, and he's stating he's trying to run it on Linux.


Executable word is not dedicated to any platform.... and there is a gdalinfo utility available for linux. So I thought its clear..


It certainly wasn't clear to me. Especially when one post said this:
Elvie D'Souza wrote:The code runs fine on windows but fails on Linux.

To me this immediately raises the possibility that Elvie expected a Windows executable to run on Linux. Especially when the name of the program was given in Windows format. Of course that might not actually be the case, and it probably isn't because of this:
Elvie D'Souza wrote:However, when I open a terminal and run gdalinfo, it executes.

But there's certainly enough unclarity in the post to point that possibility out.
 
Elvie D'Souza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry for making my post unclear.

@ Prem: I don't get any error. Gdalinfo is used to display the contents/properties of a georeferenced tiff file. When I try running the executable on LINUX, i don't get an output.


 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Stephan & Paul ; Agree with you guys .... Sorry I think I was behaving very adamant there ...

@Elvie
program just hangs without giving any output OR completes without any output?

Can you please post your complete code?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic