I'm trying to get my java program to execute a jar file which is located on a USB-drive, and I got the code to find the specific file and it's path already but I can't find anything online about how to run said file.
Can anyone help me or direct me to where I can find how to do this?
To clarify, this is not asking how to open a jar file from the cmd, this is asking how to open a jar file from a different java application. This is somewhat related to: how to run a jar file and running command line in java as it combines both of them.
-
1Duplicate of "How to run a JAR file" and "Running Command Line in Java".Andreas– Andreas2016年12月30日 19:19:03 +00:00Commented Dec 30, 2016 at 19:19
-
This first one did not help me, the second one did. Thank you very muchUrgaan– Urgaan2016年12月30日 19:24:31 +00:00Commented Dec 30, 2016 at 19:24
1 Answer 1
You need to execute java -jar <fully qualified path for your jar on usb> from your java program by using Runtime or ProcessBuilder class.