TAGS :Viewed: 24 - Published at: a few seconds ago

[ Java, JFileChooser & Windows Network Shares WITH Password Protection ]

I need to present to the user or my application a dialogue in which that point to a particular file so naturally the easiest choice is to use a JFileChooser.

However the file that needs to be selected is on a Windows network drive/share but it is mapped to a drive on the host computer running my app. The network share IS password and JFileChooser does present the drive in its dialoge but it cannot browse the drive until I use another program e.g. Windows Explorer to view the network share where it will ask for the password.

Is it possible for the JFileChooser to request the user for a password? Does JFileChooser receive notification from the system that password/authentication is required? Using the Sun example here, it just fails silently which is NOT what I want to happen. I want the user to be prompted for a password. Can I do this?

Answer 1


PasswordAuthentication may come in handy in this case.. Example can be found here