在 NetBeans 6.9 中找不到主类
每当我加载 NetBeans 6.9(以前的版本也发生类似错误)时,我让 NetBeans 完成扫描我的项目,完成后我尝试运行一个指向具有 main 方法的类的配置文件,NetBeans 总是说主类不是发现,即使一旦错误弹出它就会显示在类列表中。
如果我从列表中选择类并单击“确定”,则会再次发生相同的错误(找不到主类)。
如果我编译主类,我仍然遇到同样的问题。
我想如果我重建整个项目我仍然会遇到同样的问题。 ->当我编译主项目时,它会编译所有项目,甚至是那些已关闭的项目。 到底是怎么回事?
到目前为止,我发现解决此问题的唯一方法是关闭项目并重新打开它,然后等待项目扫描再次完成。
这非常烦人。有解决办法吗?
我注意到的另一个奇怪的事情是,我的项目似乎构建到了错误的 JAR 文件名中(尽管如果我执行上述关闭并重新打开项目的步骤,它仍然有效)。我有两个具有不同名称的项目,即使在多次关闭另一个项目并重新启动 NetBeans 后,当我构建第一个项目时,它仍使用已关闭很长时间的第二个项目的 JAR 文件名。
Whenever I load NetBeans 6.9 (similar errors happened on previous versions also) then I let NetBeans finish scanning my projects and once it's done I try to run a profile which points to a class with a main method, NetBeans always says the main class is not found, even though it shows up in the list of classes once the error pops up.
If I select the class from the list and hit OK, the same error happens again (main class not found).
If I compile the main class, I still get the same problem.
I think I still get the same issue if I rebuild the entire project.
-> when I compile the main project it compiles all projects, even those that are closed.
What is going on?
The only way I have found so far to work around this is to close the project and re-open it and wait for the project scan to finish again.
This is incredibly annoying. Is there a fix for this?
Another strange thing I noticed is that my project seems to be building into the wrong JAR file name (though if I do the above step of closing and reopening the project it still works). I have two projects with different names, and even after having closed the other project and restarted NetBeans a lot of times, when I build the first project it uses the JAR file name for the second project that has been closed for a long time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我通过删除 NetBeans 的缓存修复了非常相似的行为。删除文件夹
User\.netbeans\6.9\var\cache\index\
。Windows 7 和 Netbeans 7.2:
用户\应用程序数据\本地\NetBeans\缓存\7.2\索引
I fixed a very similar behaviour by deleting NetBeans's cache. Delete the folder
User\.netbeans\6.9\var\cache\index\
.Windows 7 and Netbeans 7.2:
User\AppData\Local\NetBeans\Cache\7.2\index
我没有阅读完整的问题,但尝试:右键单击项目>属性>运行>浏览主类,
否则尝试创建一个新项目,然后将
scr
文件夹从旧项目复制到新项目。I didn't read the complete question, but try: Right click project > properties > run > browse for main class
Else try making a new project and then copy the
scr
folder from the old one to the new project.对于 Windows 8
删除此目录 C:\Users\Shubham\AppData\Local\NetBeans\Cache
在执行此操作之前关闭 netbeans。
再次启动 Netbeans 并让它读取该项目。
测试项目。运行项目。它应该工作正常。
For windows 8
Delete this directory C:\Users\Shubham\AppData\Local\NetBeans\Cache
Before doing so close netbeans.
Start Netbeans again and let it read the project.
Test project. Run project. It should work fine.