• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

using .exe in the .jar  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm doing a java program that needs to execute a .exe file, and when I finish I would like to make a .jar file.

Can I put the .exe file inside the jar and execute it from within?

thanks
 
author
Posts: 23813
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barring new enhancements that I don't know about, the answer is "yes" for the first part and "no" for the second.

You can place an exe into a jar file, as you can place any file into a jar file, but the JVM can't execute it.

However, you can have your code check a directory for the exe, and execute it, if it is there. And if it is not, scan the jar files in the classpath for the exe file, and copy it to the directory, prior to executing it.

Henry
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!