简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM