Hi, I am wondering how difficult (or possible?) it is to load a webpage from a CLI program written in Java. I am imagining a menu based program, where the user can enter a URL as a String, whereupon the program loads the default browsers (or a particular browser for that matter) and directs it to the entered URL.
I tried searching the forums for this, but may have entered the wrong search criteria as I came up with nothing.
I've never tried this myself, but I think you will want to look at the ProcessBuilder class (new with Java 1.5) and/or the exec method in the Runtime class. Searching for examples using these should get you headed in the right direction.
Originally posted by Flo Powers: I am imagining a menu based program, where the user can enter a URL as a String, whereupon the program loads the default browsers (or a particular browser for that matter) and directs it to the entered URL.
One problem might be that Java wouldn't know what the default browser is as it is OS independent. I've written an applet that takes a URL and directs the browser to that URL. I imagine that you would probably, at least, have to write code to start the browser of your choice using the exec() method. [ February 05, 2006: Message edited by: Marilyn de Queiroz ]
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
posted 13 years ago
Hi, thanks for the replies. I've managed to make the program load the browser, but am unsure about the part that directs the browser to a particular URL. The program inputs from the user a URL as a String. I guess what I'm looking for is the DOS command to load a web browser and direct it to a particular URL...
Bras cause cancer. And tiny ads:
Create Edit Print & Convert PDF Using Free API with Java