How to solve java.lang.NoClassDefFoundError?

前端 未结 27 2085
暗喜
暗喜 2020-11-21 06:04

I\'ve tried both the example in Oracle\'s Java Tutorials. They both compile fine, but at run-time, both come up with this error:

Exception in thread \"main\"         


        
27条回答
  •  萌比男神i
    2020-11-21 06:33

    Don't use test classes outside the module

    I do not have a solution, just another flavour of the "present at compilation, absent at run time" case.

    I was trying to use a very convenient method from a JUnit test class from another test class which resides in a different module. That's a no-no, since test code is not part of the packaged jar, but I didn't realize because it appears visible for the user class from within Eclipse.

    My solution was to place the method in a existing utilities class that is part of the production code.

提交回复
热议问题