Java Tips: How to open a file with default editor from Java applicationsBy Angsuman Chakraborty, Gaea News Network
Monday, February 8, 2010
For a long time we couldn’t easily use Java applications to open the default (for the operating system) editor application (like notepad in Windows Operating Systems for text files). Starting with JDK 1.6 you can use the java.awt.Desktop class to easily launch the default editor (of your operating system) from Java applications. Read below for more details and the code.
java.net.URI uri = new URI(”http://gaeatimes.com“);
The documentation for edit() states: Launches the associated editor application and opens a file for editing.
Note: The EDIT action is not supported in CentOS 5.x systems. Let us know if you have success on your Operating System.
Did you like this tip? Consider subscribing to our site for more such tips.