我为我的 gwt 项目下载了 gflot。为了了解这个库,我创建了一个名为“FlotDemo”的测试项目。我正在使用 Eclipse 并在项目创建向导的帮助下创建了一个普通的 gwt 项目(带有问候 servlet 的东西等等)
这就是我所做的:
- 下载 gflot-3.1.1.jar 并将其复制到 /war/WEB-INF/lib
- 在 Project->Properties->Java Build Path->Libraries 中添加 gflot-jar 到路径
- 添加
<inherits name="com.googlecode.gflot.GFlot"/>
到我的“FlotDemo.gwt.xml” - 转到gFlot 示例并将其复制到我的 EntryPoint 类
因此,之后我的 Eclipse 代码如下图所示:
如您所见,eclipse 无法解析库中的对象。当我启动应用程序并尝试在 http://'127.0.0.1:8888'/FlotDemo.html?gwt.codesvr=127.0.0.1:9997 下访问它时,我收到以下错误:
[DEBUG] [flotdemo] - Validating units:
[TRACE] [flotdemo] - Finding entry point classes
[ERROR] [flotdemo] - Errors in 'file:/Users/Tom/MeineDaten/Java/FlotDemo/src/flotdemo/client/FlotDemo.java'
[ERROR] [flotdemo] - Line 15: SimplePlot cannot be resolved to a type
[ERROR] [flotdemo] - Line 15: No source code is available for type SimplePlot; did you forget to inherit a required module?
[ERROR] [flotdemo] - Line 20: Widget cannot be resolved to a type
[ERROR] [flotdemo] - Line 20: No source code is available for type Widget; did you forget to inherit a required module?
[ERROR] [flotdemo] - Line 22: PlotModel cannot be resolved to a type
[ERROR] [flotdemo] - Line 22: PlotModel cannot be resolved to a type
[ERROR] [flotdemo] - Line 23: PlotOptions cannot be resolved to a type
[ERROR] [flotdemo] - Line 23: PlotOptions cannot be resolved
[ERROR] [flotdemo] - Line 24: LegendOptions cannot be resolved
[ERROR] [flotdemo] - Line 25: LegendPosition cannot be resolved
[ERROR] [flotdemo] - Line 26: GridOptions cannot be resolved
[ERROR] [flotdemo] - Line 29: SimplePlot cannot be resolved to a type
[ERROR] [flotdemo] - Line 29: SimplePlot cannot be resolved to a type
[ERROR] [flotdemo] - Line 42: UiHandler cannot be resolved to a type
....and so on...
这里有什么问题?
更新:类路径不应该有任何问题。看看下面的截图:
左边是包资源管理器,右边是类路径配置
我认为这应该是对的。至少我在这里没有看到错误。那么还能是什么呢?
好的,我想我现在知道问题所在了。我查看了 MANIFEST.MF 文件。在那里我可以找到以下条目:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Nico
Build-Jdk: 1.7.0_07
因此,由于我使用的是 Java 1.6,所以这应该是问题的原因。但是,Java 1.6 没有编译版本。如何将源代码编译成 JAR 文件?