Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Desktop Integration: open a file with a custom application

Tags:

java

how can I open a file from within a java program with a custom application?

Desktop.getDesktop().open(file);

opens the file only with the systems default application. What I need is something like

open(myapp, file);
like image 746
Eike Cochu Avatar asked Mar 19 '26 18:03

Eike Cochu


1 Answers

If the target application accepts files to open as arguments, then you could do the following:

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("CustomApp "+filename);
like image 144
GETah Avatar answered Mar 22 '26 07:03

GETah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!