Index of /jcifs/src

      Name                    Last modified       Size  Description

[DIR] Parent Directory 05-Jan-2001 02:32 - [TXT] _README.txt 05-Jan-2001 02:30 6k [DIR] docs/ 05-Jan-2001 02:54 - [DIR] examples/ 05-Jan-2001 02:29 - [   ] jcifs-0.4b1.jar 05-Jan-2001 02:32 144k [   ] jcifs-0.4b1.tgz 05-Jan-2001 02:32 191k [   ] jcifs-0.4b1.zip 05-Jan-2001 02:32 250k [   ] jcifs-0.4dev1.tgz 05-Jan-2001 02:32 501k [   ] jcifs-0.4dev1.zip 05-Jan-2001 02:32 578k [DIR] src/ 05-Jan-2001 02:29 -

Fri Jan  5 01:54:12 EST 2001

ALERT! A serious bug was fixed and new jcifs-0.4b1 packages are now
available. If two different hostnames where queried quickly the returned
addresses could get mixed up because the shared name query transaction
id that keeps concurrent responses mapped to their callers was not being
incremented. It was a trivial fix.

FILES:

   jcifs-0.4b1.tgz     jar and javadoc only for UNIX
   jcifs-0.4b1.zip     jar and javadoc only for WINDOWS
   jcifs-0.4dev1.tgz   source and build env for UNIX
   jcifs-0.4dev1.zip   source and build env for WINDOWS


Mon Jan  1 23:03:55 EST 2001

If you have *any* trouble please let us know on the mailing list by
sending mail to jcifs@samba.org or to myself at mballen@erols.com and
Michael_B_Allen@ml.com.

Happy New Year,
Michael B. Allen <mballen@erols.com>


                               JCIFS
           Common Internet File System Client in 100% Java
                      http://jcifs.samba.org


This is the JCIFS SMB client library written in Java. In short it will
enable Java applications to remotely access shared directories on SMB
file servers(i.e. a Microsoft Windows "share"). It is a fairly religious
implementation of the CIFS specification supporting Unicode, batching,
multiplexing, encrypted authentication, transactions, and more. It is
licensed under LGPL which means commercial organizations can legitimately
use it with their propertietary code(you just can't modify the library
itself without reciprocation).

REQUIREMENTS:

JCIFS requires the Java 2 platform.

INSTALLATION

Just add the jar file to you classpath as you would with any other
jar. More specifically:

UNIX:

1) Go to http://jcifs.samba.org and download jcifs-0.4b.tgz
2) Put it someplace reasonable and extract it with:

  $ gunzip jcifs-0.4b.tgz
  $ tar -xvf jcifs-0.4b.tar

3) Add the jar to your classpath. There are two ways to do this. One is to
explicitly set it on the command line when you run your application like:

  $ java -cp path/to/jcifs-0.4b.jar MyApplication

or perhaps export it in your .profile/.bash_profile like:

  CLASSPATH=$CLASSPATH:/home/mike/java/lib/jcifs-0.4b.jar
  export CLASSPATH

WINDOWS:

1) Go to http://jcifs.samba.org and download jcifs-0.4b.zip
2) Extract it with winzip and put the files someplace reasonable.
3) Add the jar to your classpath. There are two ways to do this. One is to
explicitly set it on the command line when you run your application like:

  C:\jcifs> java -cp jcifs-0.4b.jar MyApplication

The other way is to alter your system environment but I'm not confident
I can tell you accurately how to do that.

RUNNING JCIFS

In general the public API is extremely simple. The jcifs.smb.SmbFile,
jcifs.smb.SmbFileInputStream, and jcifs.smb.SmbFileOutputStream
classes are analogous to the java.io.File, java.io.FileInputStream,
and java.io.FileOutputStream classes so if you know how to use those it
should be quite obvious how to use JCIFS provided you set any necessary
properties(such as a nameserver) and understand the smb:// URL syntax.

Here's an example to retrieve a file:

  import jcifs.smb.*;

  jcifs.util.Config.setProperty( "nameserver", "192.168.1.230" );
  SmbFileInputStream in = new SmbFileInputStream(
       "smb://username:password@host/c/My Documents/report.txt" );
  byte[] b = new byte[65535];
  int n;
  while(( n = in.read( b )) > 0 ) {
      System.out.write( b, 0, n );
  }

You can also write, rename, list contents of a directory, ...etc.

The protocol handler for java.net.URL is also in place which means you
retrieve files using the URL class as you would with other protocols. For
example:

jcifs.util.Config.init();
URL url = new URL( "smb://user:pass@host/share/dir/file.txt" );
InputStream in = url.openStream();

This will also work with whatever else uses the URL class internally. For
example if you use RMI you can serve class files from an SMB share and
use the codebase property:

-Djava.rmi.server.codebase=smb://mymachine/c/download/myapp.jar

Or you could just share the directory your working in!

Note: Calling jcifs.util.Config.init() does nothing but ensure it's static
initializer does:

  Properties sys = System.getProperties();
  sys.put( "java.protocol.handler.pkgs", "jcifs" );

which you might choose to do yourself. Under certain conditions it may
be necessary to write a StreamHandlerFactory to install the jcifs protocol
handler(I actually have this code BTW but it's pretty trivial).

To execute the Put example you might do:

$ java -cp examples:jcifs-0.4b.jar Put smb://usr:pass@host/share/file.zip
##########
582K transfered

API documentation is included and if you have any questions get on the
JCIFS mailing list at

  http://lists.samba.org/listinfo/jcifs

WHAT IS SMB AND CIFS?

SMB stands for Server Message Block which is an application layer
networking protocol for file and print sharing. It is the de-facto
networking protocol for Microsoft Windows platforms. CIFS stands for
Common Internet File System and is the more generic name for all that
encompasses the protocol and its many layers. Collectively this is the
networking protocol used when you "map network drive", issue "net use *
\\server\share" commands, use smbclient on UNIX, smbfs on Linux, Sharity,
OS2, and others.

WHY DO YOU NEED JCIFS?

This client is 100% Java and will work the same in a variety of
environments from Palm Pilots and applets to any UNIX that supports
Java. Naturally you can choose to run your applications on a platform
that supports mapping or mounting remote volumes into the local
filesystem but this assumes you know what shares you are accessing in
advance and what platform your application is running on(do you use
/mnt/pnt or H:\dir). Such an approach is not portable, unstable due to
unnecessary dependencies, and can be difficult to manage. JCIFS offers
Java applications that require access to SMB file services portability
and therefore the added stability that the UNIX environment can
provide. The JCIFS infrastructure is also highly extensible. If there
is a demand it will include a great deal of additional functionality
not available through a filesystem API such as printing, RPC, NT file
change notification, etc.

ACKNOWLEDGEMENTS

Special thanks to the Samba organization and Christopher R. Hertel for
starting the JCIFS project.