In my application I have to Upload,download files to and from windows shared drive where my java App server which is Tomcat server is running on Unix environment. Is there any Java API or any java Open source tools that does my Job?
-
Maybe _you_ should do your job in the first place. You might want to check [Apache Commons FileUpload](https://commons.apache.org/fileupload/), but anyway file up/downloading has been covered extensively at SO. – f_puras Oct 05 '12 at 19:53
3 Answers
You didn't mention what you've tried so far. Just to help out:
Option 1: Mount shared folder "\shared\" on a local directory using SAMBA. You mount "\shared\" to "/mnt/myshared/" and then upload or download file in the path "/mnt/myshared/myfiles" from your java app.(You need to write command to mount the directory via ascript or manually and then run your java app and access the directory like native directory.)
Option 2: Use jCIFS. The jCIFS library can be used to access Windows Shared directories. Its API is similar to the File and FileI/OStream classes in java.io if you prefer a pure java approach.
The above are the most preferred generic solutions. Also do make sure to update /etc/hosts or any specific configuration files, so that the shared directory and the server become accessible from unix.

- 6,464
- 23
- 42
-
I didn't try with any of the tools that u mentioned above.I am using apache FileNameUtils to convert my windows path to Unix and tried it.But when later i thought about it i got the point if i want to Upload a file I have first upload to Unix server where my app server is running on and then to windows share.But i will try above what u suggested, – SRy Oct 07 '12 at 17:55
-
When I discussed with my server admins they said they can't mount "SAMBA' ,So I need to follow the second approach. – SRy Oct 08 '12 at 17:27
-
Well, if its a production system, then may be SAMBA will most probably, not be allowed. I use jCIFS in a production project (SAMBA only for internal clusters) and it works pretty well. The jCIFS website mentioned to, has plenty of articles,sample code and user guides to implement your own custom I/O system. I did start my own code from there. :) Also, do google the jCIFS implementations. – askmish Oct 09 '12 at 16:24
-
What if my production enviroment have firewalls when intreract with other systems? does this jcifs works perfectly at that point? – SRy Oct 09 '12 at 16:56
-
jCIFS doesn't affect any firewall. Its just an API for your app. Its how you access your app(or how your app access stuff), across the firewalls and how your firewall is configured(what ports to allow, what kind of traffic to allow, etc.), that matters. Its all your code that will do the talking. If you find any issues, you need to play around with your firewall for the right settings(may not be allowed in production) or just your own code. – askmish Oct 10 '12 at 16:06
While jcifs is good, you actually might find that if you can architecturally mount the Windows drive via samba on the Linux machine and then use simple File I/O ops in Java to read/write to the filesystem, it may work out better.

- 608
- 4
- 7