Search code examples
javapackagenoclassdeffounderrorinstrumentation

Java packages: no class def found


so I've tried many of the solutions that are present in this website but none could help me.

The problem: I have my project files structured like this:

cnv/webserver/aplication/insProj.java

cnv/webserver/aplication/IntFactorization.java

and both are in the package webserver.aplication.

to compile and run i do this: starting at the folder cnv and with the $CLASSPATH=/home/ll/Documents/cnv

cd webserver/aplication
javac -source 1.4 insProj.java
javac IntFactorization.java
cd ..
cd ..
java -XX:-UseSplitVerifier webserver.aplication.insProj ./webserver/aplication/IntFactorization.class
java -XX:-UseSplitVerifier webserver.aplication.IntFactorization 5

When executing this last instruction, it returns an exception:

Factoring 5...
Exception in thread "main" java.lang.NoClassDefFoundError: webserver.aplication.insProj
at webserver.aplication.IntFactorization.calcPrimeFactors(IntFactorization.java:22)
at webserver.aplication.IntFactorization.main(IntFactorization.java:59)

The instrumentations i'm making is incrementing a counter when a given method is executed and creating a file when the class ends execution. I know this works because i've tested outside these packages and it works fine.


Solution

  • It seems BIT doesn't work well with packages. In the end, I removed insProj from any package and inserted its folder in the classpath. Then it began to work.