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

Working with Java in Linux - how to execute exe files

 
christine clarin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello, i'm a beginner in using java in linux, maybe you can help me with this problem:

i need to execute an exe file from java...how do i do this? for example i have an application named sga, in linux we execute this as ./sga right? how about if i want to execute it within a java program? apparently, this doesn't work:

Runtime run = Runtime.getRuntime ();
Process pp = run.execute ("./sga");

note that sga and my java code are in the same directory. Am i doing this correctly? thank you. hope you can help me on this one. Will appreciate it a lot!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49396
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somebody on the ranch referred to this old article, which says one has to redirect the .out and .err PrintStreams. Otherwise what happens is that your ./sga program executes and you don't see any output.

That might be your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic