我目前正在编写Java Swing应用程序。
这是我期望发生的过程:
我遇到的问题发生在步骤2。其中一个后台进程利用了一个如下所示的枚举:
public enum FilePaths {
MAIN_AUTH,
MAIN_AUTH_CREDS,
MAIN_ACTIONS,
MAIN_FETCH,
MAIN_META,
MAIN_RESRS,
TEST_AUTH,
TEST_AUTH_CREDS,
TEST_ACTIONS,
TEST_FETCH,
TEST_META,
TEST_RESRS;
}
当到达使用此枚举的第一个方法时执行失败,向我显示以下错误:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: .../gui/guicontroller/authentication/FilePaths
Caused by: java.lang.ClassNotFoundException: ...gui.guicontroller.authentication.FilePaths
这是Swing中最初启动后台执行的方法:
private class createButtonClicked implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
String message = guiController.rename();
console.append(message);
if (!guiController.getSessions()) {
String remove = guiController.remove();
console.append(removeSessions);
}
String addFields = guiController.writeData();
console.append(addFields);
}
}
概述:-控制台:JTextArea添加消息-guiController:视图和模型之间的控制器-named():使用ProcessBuilder(内部使用waitFor())运行bash脚本(不会导致错误!)-remove():导致错误并且第一次使用枚举的方法调用
到目前为止我尝试过的:
编辑:所有代码都是我的,没有拼写错误。已经检查过了。
EDIT2:这是更多代码:
public class GuiController {
private AuthenticationParser authenticationParser;
...
public String remove() {
return authenticationParser.remove();
}
}
import static ...gui.guicontroller.authentication.FilePaths.*;
public class AuthenticationParser {
...
public String remove() {
String path = GuiUtils.generatePath(MAIN_AUTH_CREDS, name);
...
}
}
remove()
中显示的行是导致异常的原因。不会调用方法generatePath()
。GuiController位于... gui.guicontroller下。 AuthenticationParser位于... gui.guicontroller.authentication下,与FilePaths相同。
我目前正在编写Java Swing应用程序。这是我期望发生的过程:用户单击一个按钮在后台运行多个任务任务完成后,一个...
如果您说JUnit执行正常,而swing执行会产生ClassNotFound异常,请检查有问题的类(FilePaths
)是否位于主源目录中,而不是在测试目录中。