-2

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.

Community
  • 1
  • 1
Urgaan
  • 23
  • 5
  • 1
    Duplicate of "[How to run a JAR file](http://stackoverflow.com/q/1238145/5221149)" and "[Running Command Line in Java](http://stackoverflow.com/q/8496494/5221149)". – Andreas Dec 30 '16 at 19:19
  • This first one did not help me, the second one did. Thank you very much – Urgaan Dec 30 '16 at 19:24

1 Answers1

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.

Sanjeev
  • 9,876
  • 2
  • 22
  • 33