I have a Windows program with the following flow:
generated config file -> user edits config file -> use config file
Ideally I want to launch the system default editor for the given file type/extension (.cfg, .ini, .txt), which can be done with java.awt.Desktop.edit().
But since the program continues execution once the editor has started, I have no idea how to check that the user actually closed the editor again :\
I have seen this be done in numeous applications, albeit most on Linux and probably non-java.
Also, since users are “stupid”, configuring a default editor from within my application is way too complicated. It might be acceptable to use a standard program, e.g. notepad which is ensured to almost always be installed on Windows computers.
Just figured out the notepad solution — doh! it was quite obvious 🙂
Use
Runtime.exec()andProcess.waitFor():