英文:
IntelliJ says build failed and through Nullpointer Exception
问题
The project在编译时显示零错误,但在构建过程中开始执行时崩溃,并显示以下错误:
Module project_name production java.lang.NullPointerException: 不允许在 THashSet 中使用空元素
但是当我将项目的目录从D盘更改为C盘时,同样的项目开始正常工作。为什么会发生这种情况,我无法解决。请帮忙!
在注释掉这段代码后,它开始工作了,在取消注释的情况下,代码没有变化,它也能正常工作。
// if main db not loaded
if (!Get_db_path.Main_not_found && Db_Connect.conn == null) {
Sel_db.connect(); // selected database
Sel_db_error();
} // display error
Main_db_error(Get_db_path.Main_not_found);
GetToggleStatus();
英文:
The project shows zero errors at compile time but when it starts to execute during build it crashes and says:
Module project_name production java.lang.NullPointerException: null elements are not allowed in THashSet
But the same project start working properly when I change its directory from D to C drive. Why this happen I'm unable to solve. Please help!
After comment this code it starts working and after disabling comment with no change in code it also works fine.
// if main db not loaded
if (!Get_db_path.Main_not_found && Db_Connect.conn == null) {
Sel_db.connect(); // selected database
Sel_db_error();
} // display error
Main_db_error(Get_db_path.Main_not_found);
GetToggleStatus();
答案1
得分: 6
这突然发生在我编译运行main
方法时。我在IntelliJ中通过重新构建项目来解决了这个问题。
--> 前往Build菜单,然后点击Rebuild Project。
下次你运行main
方法时,它应该可以正常工作。
<sub>顺便说一句:我在另一个情境中也遇到过这个问题:使用PrintWriter
写入ByteArrayOutputStream
。</sub>
英文:
This happened suddenly to me at compile time when running the main
method.
I solved it in Intellj by just rebuilding the project.
--> Go to the Build menu and click on Rebuild Project.
Next time you run the main
method it should just work again.
<sub>Btw: I had this problem in another context: writing to ByteArrayOutputStream
with PrintWriter
.</sub>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论