当我从“默认包”重命名包时,出现类未找到异常

发布于 2024-11-09 00:39:43 字数 122 浏览 0 评论 0原文

当我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-11-16 00:39:43

我的猜测是,您仍在尝试使用现有的应用程序启动器启动应用程序,该启动器引用“默认”包中的类。

创建一个新的启动器,或编辑现有启动器的详细信息。

当然,这是假设您在启动时遇到异常。如果情况并非如此,您需要向我们提供更多详细信息。

编辑:好的,现在您已经发布了异常,它更有意义 - 您正在尝试反序列化包含对类 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 override resolveClass.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文