• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

running exe files from JAR

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic