Netbeans Ghost 文件显示停止,如何修复它?
在过去的几年里,我在 Netbeans 中遇到了“幽灵文件”,但我没有证据,所以我不得不忍受它,当我试图解释这种情况时,很难相信,现在我有了证明它是一个表演障碍,有什么解决办法吗?
事情是这样的,我有一个已经使用了很多年的Java类,有点像一个工具,随着我有更多的经验,我添加了一些,但是偶尔,在我添加了一个新方法并使用它在另一个类中,Netbeans 无法识别它,在我看来,Netbeans 仍在查看该类的旧副本,其中新添加的方法不存在。然而,如果我将这个更新后的类复制到另一个项目中,新方法可以正常工作并且 Netbeans 可以找到它。在 NB 6.7 中,它就像类及时冻结一样,任何新添加的内容都不会被识别,现在当我在 NB 6.9 中尝试它时,我可以抓住“幽灵”!
这是偶然发生的,昨天我更新了类后,我尝试在同一个项目的另一个类中使用新方法,红旗升起,它找不到新方法,所以我将鼠标悬停在新方法调用上,然后右键单击它,“导航”=> “追本溯源”,嘭的一声,鬼魂现身了!如果我在 NB 6.7 中执行此操作,它只会响起铃声,好像它告诉我找不到它。但在NB 6.9中,它转到“源”,这不是我的java类源文件[Get_Time.java],它是另一个生成的文件,所以我将鼠标悬停在编辑器中打开的“ghost”文件名上,名称是“C” :\Users\USER.netbeans\6.9\var\cache\index\s117\java\14\gensrc\Get_Time.java(read-only)",内容看起来像是我的源文件 Get_Time.java 的骨架,但绝对是不同,我很确定正是这个“幽灵文件”引起了问题。
在开发过程中我偶尔会改变系统时间来测试类中的不同功能,这是否会导致ghost文件混乱,如果我将当前时间更改为2016年并修改源文件,那么NB可能会在最后记录文件2016年改变了,如果我把时间改回2011年,并添加一个新函数,它不会接受它,因为它可能会比较不同版本源文件的日期并坚持“最新时间戳”?!
我希望NB永远不要保留幽灵文件,“始终使用实际源文件”,这样可以避免很多此类问题。我确实尝试删除该幽灵文件,但下次编译时,它又生成了。我不想从“C:\Users\USER.netbeans\6.9...”中删除太多内容,它可能会弄乱我的 NB 设置。无论如何,它现在是一个阻碍,我无法向类添加更多更改,它被及时冻结了,有什么解决办法吗?
In the last few years I've encountered "ghost files" in Netbeans, but I didn't have proof of it, so I had to live with it and when I tried to explain the situation, it's hard to believe, now I have proof of it and it's a show stopper, any fix for it ?
It goes like this, I have a Java class that I've been using for many years, sort of a tool, I add a bit as I have more experience, but once in a while, after I added a new method, and used it in another class, Netbeans couldn't recognize it, it seemed to me Netbeans was still looking at the old copy of the class where the newly added method didn't exist. And yet if I copied this updated class to another project, the new method works fine and Netbeans can find it. In NB 6.7 it just acted like the class froze in time, any new additions to it wouldn't be recognized, now when I tried it in NB 6.9 I could catch the "ghost" !
It happened by accident, yesterday after I updated the class, I tried to use the new method in another class in the same project, the red flag went up, it couldn't find the new method, so I moused over the new method call, and right clicked on it, "Navigate" => "Go to source", bang the ghost showed up ! If I do this in NB 6.7, it just rang a bell as if it's telling me it couldn't find it. But in NB 6.9 it goes to the "source" which is not my java class source file[Get_Time.java], it's another generated file, so I moused over the opened "ghost" file name in the editor, the name was "C:\Users\USER.netbeans\6.9\var\cache\index\s117\java\14\gensrc\Get_Time.java(read-only)", the content seemed like a skeleton of my source file Get_Time.java , but definitely different, and I am pretty sure it's this "ghost file" that's been causing problems.
During the course of development I occasionally changed the system time to test different functions in the class, could this caused the ghost file to mess up, if I change the current time to 2016 and modified the source file, then NB might record the file last changed in 2016, and if I change the time back to 2011, and add a new function, it wouldn't accept it, because it might compare the dates of different versions of source file and stick with the "latest time stamp" ?!
I wish NB never keep ghost files, "Always Use The Actual Source File", this would avoid a lot of such problems. I did try to delete that ghost file, but the next time I compiled, it's generated again. I don't want to delete too much content from "C:\Users\USER.netbeans\6.9...", it might mess up my NB setting. Anyhow, it's now a show stopper, I can't add more changes to the class, it's frozen in time, what's the fix ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是一些建议,因为我之前也被这个问题困扰过。
您是否构建了一个 jar 并手动添加了对此 jar 的依赖项?
例如
1)项目A被打包到A.jar中,并带有Time类。
2) 项目 B 依赖于 A.jar 和项目 A
3) 项目 A 中的 Time.java 已更改
4) 项目 B 将不会看到更改,因为它始终会从更改发生之前构建的 A.jar 中读取。
Just some suggestions as I got stung by this problem before.
Did you built a jar and added dependency to this jar manually?
e.g.
1) project A is packaged into A.jar with a class Time.
2) project B depends on A.jar and project A
3) Time.java in project A is changed
4) project B will not see the changes as it'll always read from the A.jar built before the change happen.
当您回到未来并前进到过去时,请尝试删除 NetBeans 的缓存(
~/.netbeans/6.9/var/cache/index/
目录)。 NetBeans 可能对文件时间戳感到有点困惑。由于像这样在日期之间跳跃有点边缘情况,我怀疑 NetBeans 会在尝试修复/处理时给予高度优先的处理。Try deleting NetBeans' cache (
~/.netbeans/6.9/var/cache/index/
directory) when you go back to the future and forward to the past. NetBeans is probably getting a bit confused by the file timestamps. Since it is somewhat of an edge case to be hopping around dates like that, I doubt it would be something NetBeans would give a high priority in attempting to fix/handle.