Jason said:
Is it possible to run an executable prior to the execution of a JAR
file? Currently, I am doing this via a batch file, but, my customer
only wants to click on the JAR file and have everything run
(additional external executable first, then JAR).
I haven't found anything online, although I'm not sure I'm searching
for the correct terminology.
Hi Jason
What about telling the OS (eg. windows / linux / macOS) that JAR-files
should be executable (using java -jar or javaw) by clicking on them.
On Windows this is the standard, when you install a new JRE.
Then simply make your manifest pointing to your main class (MANIFEST.MF
= main-class: MyMain) and calling the external executable
from within the java-main()-method [using the
java.lang.Runtime.exec()-method]?
So actually your JVM is loaded first, starting your main(), then your
exe is executed and then the rest of your bytecode will be executed.
But probably I have not understood the "everything" correctly.
Actually, the way it is stated in your question, I think its logically
impossible:
- "the custommer only wants to click on the JAR file ...
This will make the jar run first!
Except you have a link on your desktop which is called XYZ.jar and
actually points to a batch or exe-file ;-)
- ... and have everyting (whatever this is but including the JAR) run"
This will run your exe and (", then JAR"), which will call itself
recursively?
Does your customer realy mean, that the jar (which he clicked at the
beginning) has to be executed again?
Greets phi