Connecting a windows network share from Java with a specificied usernameand password

J

Jay Hulslander

Hello,
I want to connect a file on a Windows box that I can asscess with
\\IP_ADDRESS\autoload\journals.txt from a Java application running on
another windows box.

I used the File object when I was developing. Everything worked fine.
However, when I tried to deploy to an application server, I found that I
need to supply a user name and password to connect.

I am looking for an easy way to connect to a windows network share with
a user name and password from Java. I started to looking at JNI, but I
was hoping there might be an easier to use wrapper already written. Any
help would be greatly appreciated.

Thanks,
Jay
 
R

Roedy Green

I used the File object when I was developing. Everything worked fine.
However, when I tried to deploy to an application server, I found that I
need to supply a user name and password to connect.

See http://mindprod.com/applets/fileio.html
and tell it you want to read via an URL.

The question is just what sort of url will work. try an http: and a
file:

You seem to have some sort of chimera between a file system and an
http server.
 
O

Oliver Wong

Roedy Green said:
You seem to have some sort of chimera between a file system and an
http server.

The protocol he's connecting to is called SMB, and I don't know if Sun
provides any helper classes for that protocol.

The OP may want to take a look at: http://jcifs.samba.org/

- Oliver
 
J

Jay Hulslander

Thanks Oliver, this is what I was looking for. I just need to work with
the API some more to figure out how to connect to a system based on IP
address.

Thanks again,
Jay
 
R

Roedy Green

Thanks Oliver, this is what I was looking for. I just need to work with
the API some more to figure out how to connect to a system based on IP
address.

Java has a generic URL syntax for connecting to all manner of
protocols. The http: on the front of URLS says that it connect via
http protocol. file: says it connects via local file system protocol.

there are dozens of supported protocols. You will end up writing
something like smb:123.123.123.123//xxxx for your url.

The catch is you need some sort of smb protocol handler to plug into
the generic url mechanism. It may be possible to encode your URL in
such a way it masquerades as an ordinary file: request. See
http://mindprod.com/jgoss/uri.html


I have composed a short entry in the glossary about SMB, that will be
posted in an hour or two. See http://mindprod.com/jgloss/smb.html
 
R

Raymond DeCampo

Jay said:
Hello,
I want to connect a file on a Windows box that I can asscess with
\\IP_ADDRESS\autoload\journals.txt from a Java application running on
another windows box.

I used the File object when I was developing. Everything worked fine.
However, when I tried to deploy to an application server, I found that I
need to supply a user name and password to connect.

I am looking for an easy way to connect to a windows network share with
a user name and password from Java. I started to looking at JNI, but I
was hoping there might be an easier to use wrapper already written. Any
help would be greatly appreciated.

Another way to go is to have your J2EE server run as a user that has the
proper credentials. If you are running it as a service, there are
configurations available on the service panel.

I would be interested in hearing if you got anywhere trying to use the
SMB protocol directly.

HTH,
Ray
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top