On Sat, 18 Jun 2005 16:37:09 GMT, Dimitris (GIS) wrote:
> I have a menuItem, that when I press it (ActionListener) I want it to open
> an .html file (local file:// or online http://) at the explorer.
It makes more sense to open "the user's default browser", see..
<http://browserlauncher.sourceforge.net/>
> I know that this will make our application Operating System oriented, but it
> is OK.
There is no need to go Win specific on this one.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Steve W. Jackson - 20 Jun 2005 19:05 GMT
> On Sat, 18 Jun 2005 16:37:09 GMT, Dimitris (GIS) wrote:
>
[quoted text clipped - 8 lines]
>
> There is no need to go Win specific on this one.
BrowserLauncher is a bit long in the tooth for my tastes.
I recently implemented something in my app that launches either URLs or
user-selected files using the designated application, and it works for
local HTML files too. I strive to never use platform-specific code when
it's avoidable, but there are some platform-specifics involved in this
no matter what simply because the mechanism involved is specific to the
underlying OS.
Essentially, what I did was to create a URI for a local user-selected
file by using the File class's toURI() method (for a regular URL, just
use that).
For Windows 2000 and up I used a String array with elements containing
"cmd", "/c", "start", and then the URL or URI, which I then passed to a
Runtime.exec call. On Windows 98, which my app no longer supports, that
may not work becaus "cmd" command was previously "command.com".
For Mac OS X, String array contains "open" and then the URL or URI. I
would advise against supporting any Mac running a pre-OS X system in new
apps since Java there is seriously out of date and will not be updated.
The above approach hands off the URL or "file:" URI to the underlying OS
to be handled by whichever application is designated. It offers the
additional advantage of automatically letting the OS handle prompting if
no app is selected for whatever it's given.
The same approach can work in Linux if you know what desktop environment
is being used and the appropriate command to have that environment's
file management scheme handle the file. I've found that a URL and a URI
can both be handled in the KDE setting by using "kfmclient" and "exec".
And it seems true in my testing to date that "nautilus" will work for
Gnome. I've found that using "nautilus" still works for me in KDE since
it's in my path already. And taking this approach avoids the hard-wired
path issue that's used in the BrowserLauncher code.
HTH.
= Steve =

Signature
Steve W. Jackson
Montgomery, Alabama
Andrew Thompson - 20 Jun 2005 19:29 GMT
>> On Sat, 18 Jun 2005 16:37:09 GMT, Dimitris (GIS) wrote:
>>
>>> ..open an .html file ...
>>
>> <http://browserlauncher.sourceforge.net/>
..
> BrowserLauncher is a bit long in the tooth for my tastes.
>
> I recently implemented something in my app that launches either URLs or
> user-selected files using the designated application, ...
1) Will you be adding *nix support?
2) Can you supply an open source version?
[ If both 'yes', I might be interested in offering it off
my site/linking as an alternative to BL. ]

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Steve W. Jackson - 20 Jun 2005 21:11 GMT
> >> On Sat, 18 Jun 2005 16:37:09 GMT, Dimitris (GIS) wrote:
> >>
[quoted text clipped - 12 lines]
> [ If both 'yes', I might be interested in offering it off
> my site/linking as an alternative to BL. ]
The application is my company's proprietary product (SIMPROCESS), which
we support for Windows 2000 and higher as well as any Linux that is
compatible with the shared library code we use with FLEXlm licensing
(Macrovision says that means compatible with Red Hat versions 6 through
8). As a Mac supporter, I do some occasional testing on my PowerBook
and advocate for a Mac OS X version whenever I get the opportunity.
As a result, I don't have any code packaged in a way that could be made
open source or anything similar. But the previous post pretty much
described the logic I devised for Windows and Mac OS X portions.
or the Linux side, expecting that I can't readily detect the graphical
desktop manager myself, I set it up to look for a separate properties
file where the user is to give me two properties, named "file.view" and
"url.view". This allows me to let the user indicate what command to use
and supports something I learned in one of these groups some time ago,
which is that CDE on non-Solaris systems supposedly requires different
commands for a URL than for a file URI (I don't have access to such an
environment at present to test it). Naturally, it also allows the user
to choose whatever mechanism they want, even a path-oriented command,
provided it can accept a parameter (the URL or URI, as appropriate) to
do its work. I simply read in the property, break it around spaces, and
build my String array starting with those pieces.
= Steve =

Signature
Steve W. Jackson
Montgomery, Alabama