Get errors when trying to start Browser from Swing app...

T

Tomas

Hi,

I have a Swing component and when a button is pushed i want the Componet
to start an Internet Browser with a specified file or url path.

I've tried 2 different ways to do so and get error messages with both. I
have tried with JEditorPane like this:

JEditorPane jed = new JEditorPane();
jed.setContentType("text/html");
jed.setPage("www.google.com/");

But nothing happends or i get a java.util.noSuchElementException.

And i have also tried with:

Runtime.getRuntime().exec("http://www.google.com/");

And i get an IOException there with errormessage = 2.

Any idea what is wrong?

Best regards
/Tomas
 
B

Brian Palmer

Tomas said:
Hi,

I have a Swing component and when a button is pushed i want the Componet
to start an Internet Browser with a specified file or url path.

I've tried 2 different ways to do so and get error messages with both. I
have tried with JEditorPane like this:

JEditorPane jed = new JEditorPane();
jed.setContentType("text/html");
jed.setPage("www.google.com/");

But nothing happends or i get a java.util.noSuchElementException.

OK, that's an odd exception. If you post a short example, it'd be
easier for somebody to see if their results match yours.
(And is it possible that you simply didn't wait long enough for the
page to load? )
And i have also tried with:

Runtime.getRuntime().exec("http://www.google.com/");

And i get an IOException there with errormessage = 2.

If you want to open up in the system's default browser, you may want
to look at
http://browserlauncher.sourceforge.net/
for a simple class which handles a lot of the details of opening up n
external browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top