*
The moose likes Beginning Java and the fly likes opening another program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "opening another program" Watch "opening another program" New topic
Author

opening another program

Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
Hey guys, does anybody know if its possible for java to open another program like internet explorer? What I'm trying to do is use jave to write and save a html file and then use internet explorer to open it. I have already written the code to write and save the html file and it works, but I'm not sure if it is even possible to have java open up a internet explorer window. If anybody knows if it is possible or definantly impossible please let me know, also if it is possible is there a way to have it come up with my html file already displayed in the window?
Thanks in advance- Dan


-Dan
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

There's a family of exec() methods in the java.lang.Runtime() class that can launch new processes.


[Jess in Action][AskingGoodQuestions]
Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
Thanks Ernest, so if I understand this correctly to open up internet explorer I would use:


and that would open up internet explorer? If I copy/pasted this exactly into my program would it work? And do I need to import anything? Also one last tiny little thing, how can I get it to open up a specific file?
Thanks for all the help!!!
-Dan
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118
No, that wouldn't work... I think you need to learn how to read the API. When you see public Process exec(String s), that is the method signature for exec. So when you call .exec() it accepts a String, and returns a Process. You aren't supposed to rewrite it.
Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
sorry I'm new to this, so Darin, so if I understand you correctly I just need to use:


what should A be?
Thanks for correcting me
[ July 09, 2004: Message edited by: Dan Maples ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Instead of tying your program to a specific installation of internet explorer, you may prefer to make use of BrowserLauncher or the WebBrowser example in chapter 2 of Deitel's "Advanced Java 2 Platform How to Program". The source code for that book can be downloaded at http://www.deitel.com/books/downloads.html#advjHTP1


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dan Maples
Ranch Hand

Joined: Jun 21, 2004
Posts: 153
hey Dirk!!! that was exactly what I needed!!! that was perfect!!! thank you sooooo much that was sooo helpful!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: opening another program
 
Similar Threads
How to use loaded JVM instance?
IE and NN Compability
How do I open a Windows program from a Java program?
Java Plug-in: Proxy authentication with username and password
configuring editplus