Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running exe files from JAR

 
Govind battacharya
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All
How can i run an EXE file from a JAR application
i am using the following code, but it is not working. please help
Process Process;
process =Runtime.getRuntime().exec("Native.exe");
before making a JAR it was working, but from inside the jar i am not able to call this Native.exe file
please help
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Govind,
The .exe needs to be in the path for the OS to find it.
Also, welcome to JavaRanch!! Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
 
Govind battacharya
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didi'nt understood, can u give the code
(i have specified my real name only)
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for changing your name.
I am kinda swamped right now, but when you ask the operating system to execute a program, such as Native.exe it starts searching for that program following the directories that are named it the os's path parameter. This is different from the classpath that the JVM uses to search for class files.
Your choices are to
- modify the path that the user has on their machine (perhaps by dynamically concatenating onto the existing path in a bat or sh file)
- or you can name the full path for finding the Native.exe program
- you could try to get the user to put that .exe file someplace and track where they put it
In any case, once you start doing any of these you start making the solution dependant on the operating system. But then when you created the Native.exe program you must have compiled it for only one specific operating system anyway.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic