wrote:
> Hi all!
>
> I'm building an app which interfaces a tool which in turn opens files.
> My app is a server app, run as service, and will open files on other
> computers on the network. So, how do I open the network connections
> needed to be able to access remote files? I've up until now managed
> this by manually opening them with "net use" or simply browsing to the
> other computer using Explorer. But manual opening is of course not an
> option for a run-as-service application. I've browsed around java.net
> but can't figure out if that's what I need. If I open a connection with
> e.g. Socket, will it be possible to use that connection later when my
> app tries to access a remote file? (I guess that translates to: Will
> the opened connection be stored in the process' connection 'pool', for
> later use?)
>
> Don't know much at all about stuff like this so any help here greatly
> appreciated!
>
It sounds as if you are running Windows and are able to access the files
via UNC pathnames (e.g. \\servername\path\to\file). If that is the
case, simply open java.io.FileXxx as needed using the filename
"\\servername\path\to\file". (It is the underlying file system run by
the OS that handles the network connections.)
One gotcha in this scenario is that be default services will run as a
system user that typically does not have the proper authorization to
access the network paths. In this case you can configure the service to
run as a specific user that does have the proper privileges.
Be sure to test your service both when someone is logged in and when
no-one is logged in. Also, be aware that some versions of the 1.3 JRE
have bugs that can cause the JRE to terminate when a user logs out of
the machine. If you are using a 1.3 version of the JRE, search sun.com
for more information.
HTH,
Ray
--
XML is the programmer's duct tape.