Help with Java

afflictedd2

Registered
Hi everyone,

I'm able to compile from eclipse and run from it, but when I try to run the class file from command line I get this error:

$java ../flatfiles/BinParser

Exception in thread "main" java.lang.NoClassDefFoundError: ///flatfiles/BinParser

I've tried

Naix:flatfiles Naix$ export "CLASSPATH=."
Naix:flatfiles Naix$ echo $CLASSPATH
.
Naix:flatfiles Naix$ java ../flatfiles/BinParaser
Exception in thread "main" java.lang.NoClassDefFoundError: ///flatfiles/BinParser

no luck.. I don't really get how I need to set this CLASSPATH variable for it to work.

Ted
 
You give the class name as the argument to the "java" command. Since you gave argument "../flatfiles/BinParser", it assumed that you referred to the class ///flatfiles/BinParser. It tried to search the class in the current directory (in file named ///flatfiles/BinParser.class, I guess).

Why not make the ../flatfiles the current directory and try "java BinParser" there? Or, use

$java -classpath ../flatfiles BinParser

Java uses mainly two places to search bytefiles: directories and jar-archives. CLASSPATH variable lists directories and jar-archives where to search the files. If you have it set, I guess it does not use current directory for the search.
 
Back
Top