0

Basically, I want this to function the same way as when you right click on a file and say "Open with". However I am having trouble figuring out the correct way to do this from java.

Process p = Runtime.getRuntime().exec("cmd /c start " + file.getAbsolutePath());

That's all I got, but I can't figure out how to run it with the executable. Would I need to run the executable and put this in as a parameter? If so, how?

1 Answer 1

1

it really depends on the executable that you are calling.. for example notepad, it is pretty straightforward..

Process p = Runtime.getRuntime().exec("cmd /c notepad.exe " + file.getAbsolutePath());

but for many others, you might need to see its manual about using "arguments"..
and some even don't support argument usage..

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.