当我从“默认包”重命名包时,出现类未找到异常
当我从 java 中的“默认包”重命名包时,出现类未找到异常。当我在默认包中运行代码时,代码工作正常,但是当我将代码粘贴到 Eclipse 中的新 java 项目和新包中时,即使上面提到的类明显存在于新的包裹。怎么了?请帮我 :(
I get a class not found exception when i rename the package from "default package" in java. When i run the code within the default package, the code works fine but when i paste the code into a new java project in eclipse and into a new package, there is a classnotfound exception thrown even when the class referred to above is clearly present in the new package. What is wrong? please help me :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,您仍在尝试使用现有的应用程序启动器启动应用程序,该启动器引用“默认”包中的类。
创建一个新的启动器,或编辑现有启动器的详细信息。
当然,这是假设您在启动时遇到异常。如果情况并非如此,您需要向我们提供更多详细信息。
编辑:好的,现在您已经发布了异常,它更有意义 - 您正在尝试反序列化包含对类
FaceBundle
的引用的数据。重命名类会破坏序列化数据 - 就这么简单。您可以摆弄Java序列化中的东西,但我自己还没有这样做过。我怀疑您想要创建自己的
ObjectInputStream
子类并覆盖resolveClass
。My guess is that you're still trying to start the application with the existing application launcher, which is referring to the class in the "default" package.
Either create a new launcher, or edit the details of the existing one.
Of course, that's assuming you get the exception on launch. If that's not the case, you need to give us a lot more details.
EDIT: Okay, now you've posted the exception, it makes a lot more sense - you're trying to deserialize data which includes a reference to the class
FaceBundle
. Renaming classes breaks serialized data - it's as simple as that.You can fiddle around with things in Java serialization, but I haven't done so myself. I suspect you'd want to create your own subclass of
ObjectInputStream
and overrideresolveClass
.