-
October 18th, 2006, 10:01 PM
#1
Execute a file
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
-
October 19th, 2006, 04:07 AM
#2
Re: Execute a file
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
-
October 19th, 2006, 07:59 AM
#3
Re: Execute a file
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.
-
October 19th, 2006, 10:11 AM
#4
Re: Execute a file
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
Byron Tymvios
Please use [ CODE ] and [/ CODE ] tags when posting code! See THIS on how to use code tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|