简体   繁体   English

Java套件:找不到类别def

[英]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 / Web服务器/ aplication / insProj.java

cnv/webserver/aplication/IntFactorization.java CNV / Web服务器/ aplication / IntFactorization.java

and both are in the package webserver.aplication. 两者都在webserver.aplication包中。

to compile and run i do this: starting at the folder cnv and with the $CLASSPATH=/home/ll/Documents/cnv 编译和运行我这样做:从文件夹cnv和$ 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. 似乎BIT不适用于包。 In the end, I removed insProj from any package and inserted its folder in the classpath. 最后,我从任何软件包中删除了insProj,并将其文件夹插入了类路径。 Then it began to work. 然后它开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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