[jcifs] NoClassDefFoundError

Michael B Allen mba2000 at ioplex.com
Fri Oct 7 06:05:44 GMT 2005

On Thu, 06 Oct 2005 23:54:08 -0400
Mike Goppold <msg at msu.edu> wrote:

> I executed the following commands and got a strange NoClassDefFoundError 
> exception.  What's wrong?  I ran another java program which worked.  (I 
> was trying to use the AllocInfo example: 
> http://jcifs.samba.org/src/examples/AllocInfo.java)
> C:\Documents and Settings\Mike\Desktop>javac -cp jcifs-1.2.5.jar 
> AllocInfo.java

I think you might need to add the directory of the source file (.) and
I believe the proper option is -classpath so the command would be like:

  java -classpath jcifs-1.2.5.jar;. AllocInfo.java

This is a very basic Java usage issue so it's a little offtopic here
but, just for posterity, let me explain how I work the the JCIFS source
and examples.

What I do is I get the source package (of course :-) and then compile
it with 'ant compile'. Assuming you have Ant installed this will create
a directory 'build' with all the class files. Then I add "build" and
"." to my CLASSPATH environment variable. Now if I want to run an example
I just copy it up into the top level directory, compile like:

  $ cp examples/ListFiles.java .
  $ javac ListFiles.java

This is nice because I don't need to mess with -classpath and if I
modify the JCIFS source I can do 'ant compile' and the changes take
effect immediately without bothering with creating a jar.

Also, it's nice to put your credentials
(jcifs.smb.client.{domain,username,password}) into a file in the directory
above the one you unpack the source in so that you can reference it
easily when running the program:

  $ java -Djcifs.properties=../miallen.prp ListFiles smb://server/share/path/

For general Java questions I recommend the comp.lang.java.programmer
USENET newsgroup, Google Groups advanced search, and the java.sun.com

Good Luck,

More information about the jcifs mailing list