Relative path with BrowserLaucnher?

T

Tomas

Hi,

I know that the class BrowserLauncher is not part of the standard java api.
But i try anyway to ask this question here and hope somone else here use
this class and can help me. Now my question:

Can you use relative paths when opening an Browser with BrowserLauncher?
The class works well when i use an absolute path but not with relative paths
or i am making something wrong. The thing is that i want to open a browser
with a html file on my pc like this:
BrowserLauncher.openURL("catalog/myFile.html")
Nothing happends when i try like this. But with an absolute path like this
it works:
BrowserLauncher.openURL("file:///E:/catalog/catalog2/myFile.html")

Any suggestions?
Best Regards
/Tomas
 
T

Tomas

Andrew Thompson said:
....

I have downloaded BrowserLauncher, but not played
with it yet..

One suggestion. Try parsing the URL in your own prog
first and see what you get, you may need to try something
more like..
BrowserLauncher.openURL("./catalog/myFile.html")

Note the './' before the path..

HTH
I've tried with the './' and still nothing happends no error message or nothing.
Otherwise if the path is fault i use to get errormessage for that. I can
also say that i use Netscape as default Browser if that maybe has something
to do with it.

/Tomas
 
J

Jacob

Tomas said:
I've tried with the './' and still nothing happends no error message or nothing.
Otherwise if the path is fault i use to get errormessage for that. I can
also say that i use Netscape as default Browser if that maybe has something
to do with it.

BrowserLauncer make use of an external process
(Runtime.exec()) to access the browser which may
explain its error message behaviour.

Your relative paths are simply pased on to that
process, and becomes relative to your "user.dir"
directory. Check this to see what resolved path
you get, but note that there is no way you can
set "user.dir" from your program.

The best approach is probably (as Andrew already
has pointed out), to use absolute paths with
BrowserLauncher.
 

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
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top