Hello
How can I execute a file or a program with java?
Like executing a file.doc and then it opens with Microsoft Word
or executin a file.exe from java
Thank you
Printable View
Hello
How can I execute a file or a program with java?
Like executing a file.doc and then it opens with Microsoft Word
or executin a file.exe from java
Thank you
I suppose you mean you want to execute a java program. Java classes cannot be directly executed. One solution is to use Java Web Start or executable jars. There are also some programs that try to "package" java programs in an exe file. For more info you can visit this thread.
Regards,
Theodore
No, I want to execute a file or program from a java program, Like opening a web browser when someone push the button in my program or opening a file.xls with exel when the user do something in the java program.
Hi
Depending on what version of JDK you are using there are 2 different methods of doing this. Prior to JDK 5 version, have a look at the Runtime class, from JDK 5 and up have a look at the ProcessBuilder class. Both these classes allow you to run command line commands directly from Java.
Have a look HERE for how to use the Runtime class.
Have a look HERE for a paper on using ProcessBuilder
Hope This Helps