Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Execute application from java  RSS feed

 
Luca Verdi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I'm trying to run this simple code:


but I get this exception:


The path is correct; luxconsole application is there so I don't understand this exception.
what I wrong?

thank you

bye
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try ./luxconsole
In Linux and Mac, the current folder (.) is hardly ever part of the PATH variable. So unlike in Windows, you need to include the path.
 
Luca Verdi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works!
Really thank you.

bye
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Luca Verdi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, ehm..another stuff like first post;

I need to execute an LSF submit job command always from my Java app.

The command is:


where start_server is a batch script containing BSUB directives.

my code si the following:


I do not get errors but I verified that command is not executed!
Can you help me?

Thank you.
bye
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use <, >, |, && or ||, as those are not part of the commands. They are operators in your shell. Either do the file redirection yourself (using ss' getOutputStream() method), or execute the command through a shell. I'm not sure how to do it, but most shells (like bash) has an option to have it run another command.

Also, please read Please When Runtime.exec() won't before continuing. It'll help you prevent problems like hanging processes.
 
Luca Verdi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks!

using "bash -c" and in particular:



works!

Thank you for the answer

bye
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!