Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we call an executable(.exe) from Java program

 
Swaroop Reddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
I have an executable file written using Vc++ ,i want to call it in my java program in such a way it should get executed and should start working
Is it possible if so please suggest me relative links and process how to do
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to invoke some application, check out the Runtime and ProcessBuilder API.
Moving to a more appropriate forum
 
kiran kumar kondru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I think the Runtime class encompasses the execution of native code. Runtime.getRuntime().exec("notepad.exe"); for example runs the notepad. Remember that either the exe is in the PATH or give complete path to it.

This exec() method returns a Process object through which you can have more control like killing the process itself.

The following is a sample program.

 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please read the JavaWorld article "When Runtime.exec() won't". Once you start with external processes, this article is a must-read.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.lang.ProcessBuilder class makes it easier, but it simplifies the problems discussed in the Daconta article Rob quoted. You still must read it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic