-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.

asked Dec 30, 2016 at 19:11
2
  • 1
    Duplicate of "How to run a JAR file" and "Running Command Line in Java". Commented Dec 30, 2016 at 19:19
  • This first one did not help me, the second one did. Thank you very much Commented Dec 30, 2016 at 19:24

1 Answer 1

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.

answered Dec 30, 2016 at 19:14
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I didn't realise I needed to use runtime, nor have I ever worked with it (still fairly new to java).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.