My code compiled fine with the following command:
javac -cp "../lib/*" AvroReader.java
(lib is where i put my jar files)
At run time I get a ClassNotFoundException
on the following line:
DatumReader<?> dtmrdr = new GenericDatumReader();
It says it can’t find org.apache.avro.generic.GenericDatumReader
even though I’ve imported it.
Why is this happening?
Advertisement
Answer
Importing has nothing to do with loading classes or setting CLASSPATH.
Try this:
java -cp .;../lib/* Generator
Using the dot '.'
as the first entry in the CLASSPATH assumes that the Generator.class
file exists in the directory from which you’re running java, and /lib
is one level up from that directory. Adjust as needed if both of these are not correct.