my dog learned polymorphism
The moose likes Linux / UNIX and the fly likes Folder sharing in Unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Folder sharing in Unix" Watch "Folder sharing in Unix" New topic

Folder sharing in Unix

Nikhil Sun
Ranch Hand

Joined: Nov 13, 2005
Posts: 108
I have got 2 solaris systems.On the first Solaris system I have deployed a Java application.How do I read a file located in the second Solaris system?
When both are Windows systems it is possible by giving \\ip_of_second_system\shared_folder_name.But how does it work when both are Solaris systems?
Rob Spoor

Joined: Oct 27, 2005
Posts: 20273

Not a Java problem actually.

You can check if Solaris supports Samba. That's the Linux / Unix alternative for Windows' file sharing, and the two are quite compatible.

How To Ask Questions How To Answer Questions
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Even if you don't have Samba, your Solaris systems are almost guaranteed to have NFS installed.

Here's one tutorial: Network File System

Of course both Samba and NFS (and many other networked file system protocols) are designed so that you can mount the remote folder locally and use it as though it is a local folder.

However if all you want to do is copy an individual file locally then there are many other options that may make more sense for you to look at (rsync, rcp, ftp, ....)

Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

NFS is the usual unix way, not SAMBA, which is more of a reverse engineering hack to make Windoze boxes share nice.

While either will work, NFS is the usual tool in this case.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Ah yes, the things we take for granted these days.

Regardless of the OS, in order to access any file, you need a driver stack. At its highest level, the stack maintains access and status of files and their interrelationships. At the lowest levels you find the services that do data interrelationships (connecting data blocks into a file or directory) and raw data block I/O.

In the case of sharing a directory (a/k/a folder) over a network, the lower-level services that would be doing the allocation tracking and IDE/SCSI/SATA/USB I/O are replaced with network client code.

On the machine doing the sharing, a server has to be running so the client has something to talk to. Basically, this server takes the file requests and uses them to access shared files available on the server machine vis its own file system.

So to do file sharing, you need a network filesystem client driver on the client machine and a filesystem server on the target machine. And, just because people tend not to realize this, I want to emphasize that a FILE server is NOT a web server. You can have one or the other, neither or both on a machine, but the two functions are very different regardless of the fact that URLs happen to look like filesystem paths.

In Windows, the CIFS driver (originally known as SMB filesystem driver) is installed when you set up Windows Networking to work with shared files. You also get a CIFS server, which for Windows Desktop products is limited to 10 clients (Windows Server Edition lifts that limit).

The equivalent in Solaris is NFS, but the configuration model for Solaris (and for Linux) is that you have to install actual software packages for NFS client or server. NFS, however, isn't the easiest thing for a Windows client to use - unlike CIFS it's not bundled with Windows. In this case it's easier to leave Windows alone and install a CIFS server on Solaris - i.e., Samba.

CIFS and NFS are similar but not identical services. CIFS understands the Windows file attributes (including NTFS ACL info), but not Unix file attributes (Samba has to fake it). Likewise for NFS, except that NFS is slanted towards the Unix filesystem architecture.

Samba is one of the rare cases where I considered the Windows approach as more secure than Unix. NFS in its earlier years was fairly vulnerable and the situation was made worse by the fact that it did its network port assignments dynamically. You either had to run a much looser firewall than I do or take the trouble to manually lock down the port usage.

I finally mostly switched from Samba to NFS because when doing word processing, the auto-update function kept hitting obstacles. While the difference between a CIFS and NFS filesystem is generally transparent, this was an annoying exception.

Just for general info, Samba on Solaris isn't as full-functioned as it is on Linux. It doesn't provide the ability to mount SMB shares. Fortunately, however, there's a third-party product that fills that need.

And finally, just to fill in some history:

The original SMB file sharing was done via NETBIOS, which is a non-tcp/ip protocol. NETBIOS provided the bottom layer of the Windows file-sharing sriver stack, although you could connect in an IPX bottom-layer driver to communicate with Novell Netware servers. When Windows 95/NT 4.0 came out, TCP/IP was the transport mechanism of choice, so a bottom-layer driver for that protocol became part of the package as well. Since Windows File Sharing was now no longer based on NETBIOS Server Message Blocks (SMB), they named the new stack the Common Internet File System (CIFS).

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Folder sharing in Unix
jQuery in Action, 3rd edition