Java AWT - 使用 J2ME 和 J9 时的 BufferedImage 问题
我正在尝试在 AWT 中使用 BufferedImage 类。 我在 IBM 的 J9 虚拟机上使用 J2ME。
当我尝试调用 BufferedImge.getRastor() 方法时,出现以下异常:
Exception in thread "main" java.lang.NoSuchMethodError: java/awt/image/BufferedImage.getRastor()Ljava/awt/image/WritableRaster;
现在,根据我对 JVM 的了解,该错误基本上告诉我 BufferedImage 类没有名为 getRastor() 的方法,该方法返回 WritableRaster对象,但是此方法记录在 API 中,并且它来自版本 1.4.2,因此应该与 J2ME 兼容。
我不知道这是怎么回事,你能帮忙吗?
干杯,
皮特
I'm trying to use the BufferedImage class in AWT. I'm using J2ME on IBM's J9 virtual machine.
When I try and call the BufferedImge.getRastor() method I get the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: java/awt/image/BufferedImage.getRastor()Ljava/awt/image/WritableRaster;
Now, from what I know about the JVM that error is basically telling me that the BufferedImage class does not have a method called getRastor() which returns a WritableRaster object, however this method is documented in the API and it's from version 1.4.2 so should be compatable with J2ME.
I have no idea what is going on here, can you help?
Cheers,
Pete
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将无法在 J2ME 中使用 AWT 中的任何内容,因为它不受支持。
发生这种情况是因为 J2ME 没有 AWT。 AWT 旨在用于桌面应用程序 (Java SE),具有不同的用户模型和功能。
您可以查看 J2ME 文档 此处
J2ME 使用关于 GUI 的不同方法,您可以使用高级抽象 API (FORMS) 和低级 API (CANVAS)。
You won't be able to use anything from AWT in J2ME since its not supported.
That happens because J2ME doesn't have AWT. AWT is intended to be used in desktop applications (Java SE), with a different user model and functionalities.
You can take a look at J2ME docs here
J2ME uses a different approach regarding GUIs, you may use the high level abstraction API (FORMS) and the low level API (CANVAS).
我不认为这是你的答案......但既然你引用了你的例外情况并且我假设你剪切并粘贴了它,我会尽力提供帮助。
方法不是:
不是吗
?
(抱歉,如果这不是您的问题......)
I don't think this is your answer... but since you quoted your exception and I assume you cut and pasted it, I'll try to help.
Isn't the method:
not
?
(sorry if this is not what it is ailing you...)
接受的答案不正确(截至2009年8月5日)。 您可以使用哪些 API 取决于您部署的配置和配置文件组合。 但是,您确实需要参考 J2ME 文档来准确了解支持哪些 1.4 类和成员。
将 CDC 1.0 与 Personal Profile 1.1 结合使用,您将获得 Java SE 1.4 的精简版本。 Personal Profile 1.0 是 Java SE 1.3 的精简版本。 两者都有相当完整的 AWT 实现(不过没有 Swing)。
实际上,我们在手持/PDA 设备上使用 J9 的 CDC/PP 相当成功。
The accepted answer is not correct (as of 2009-08-05). Exactly which API's you have available depends on the configuration and profile combination you deploy. However, you do need to refer to the J2ME documentation for exactly which 1.4 classes and members are supported.
Using CDC 1.0 with Personal Profile 1.1 you get a cut-down version of Java SE 1.4. Personal Profile 1.0 is a cut-down Java SE 1.3. Both have a fairly complete implementation of AWT (no Swing, though).
We actually use J9's CDC/PP on handheld/PDA devices quite successfully.