Posts

Showing posts with the label run application from java

Run a programme by java application

You may have encountered situations where you wish to run a programme say Web Browser (FireFox) from your Java programme. It is very simple Find the location of the actual executable of the programme. As in the case of FireFox Web Browser, the actual executable file is placed at C:\Program Files\Mozilla Firefox\firefox.exe You can use the following code to run it from your Java application Runtime runtime = Runtime.getRuntime(); runtime.exec("K:/Program Files/Mozilla Firefox/firefox.exe"); (YOU MUST USE A TRY CATCH BLOCK. Just excluded them for clarity) ENJOY programming :-) Here is a great tip if you wish to launch the native applications for specific tasks such as sending a mail, opening the native web browser. public static void main(String[] args) { Desktop dt = Desktop.getDesktop(); try { try { dt.browse(new URI("http://yahoo.com")); } catch (URISyntaxException ex) { Lo...