Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connecting to shared folder in windows

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys ,

I need to connect to a shared folder on a remote windows machine through java , where i put my domain authentication (username and password ) in the code , here is my code


Please advice ...
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JCIFS. Your code would work if you didn't need to connect with a different user name / password than those you logged into Windows with.
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Check out JCIFS. Your code would work if you didn't need to connect with a different user name / password than those you logged into Windows with.


Thanks for your reply , Ya you are right , but actually i need to connect using username and password , do you think JCIFS will help, no other way without using JCIFS? ,any tutorials for it ?
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Main page
Javadoc (you will want jcifs.smb.SmbFile)

After that it should be pretty easy; use SmbFile where you normally use java.io.File. The rest is more or less the same, only SmbFile has its own methods for getting an input or output stream to it, instead of separate classes FileInputStream and FileOutputStream.
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ,

I used the JCIFS but when ii'm trying to connect i got this exception :

although i;m sure from the username and password !!

Here is my code :


Anything i'm missing ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic