• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

running a .exe from JAVA on Linux

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 76450
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Runtime.exec() won't.
 
Elvie D'Souza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 14306
321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 14306
321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 27371
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic