• Post Reply Bookmark Topic Watch Topic
  • New Topic

using .exe in the .jar  RSS feed

 
Mike Phillip
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
 
Henry Wong
author
Sheriff
Posts: 23295
125
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!