• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Loading an application from a Java Program

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

EDIT: I found this Sun Developer tip comparing Runtime.exec and ProcessBuilder. Hope it helps.
[ February 05, 2006: Message edited by: marc weber ]
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Flo Powers
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...

Thanks!
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic