【问题标题】:Eclipse Oxygen Source Level ChangeEclipse 氧源级别更改
【发布时间】:2019-03-12 18:56:50
【问题描述】:

我正在使用 Eclipse Oxygen 并尝试将我的 sourceLevel 更改为 1.8。每次我尝试运行我的程序时,我都会收到以下控制台输出:

Runing CodeServer with parameters: [-noprecompile, -port, 54953, - 
    sourceLevel, 1.7, -bindAddress, 127.0.0.1, -launcherDir, 
C:\Users\heyerj\eclipse-workspace\Zoo\war, -logLevel, INFO, com.zoo.gxt.project.Zoo]
Super Dev Mode starting up
workDir: C:\Users\heyerj\AppData\Local\Temp\gwt-codeserver-4320248131930738092.tmp
    Loading Java files in com.zoo.gxt.project.Zoo.
    Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Finding entry point classes
      Tracing compile failure path for type 'com.zoo.gxt.project.client.Zoo'
        [ERROR] Errors in 'file:/C:/Users/heyerj/eclipse- 
        workspace/Zoo/src/com/zoo/gxt/project/client/Zoo.java'
        [ERROR] Line 215: Lambda expressions are allowed only at source level 1.8 or above
        [ERROR] Line 223: Lambda expressions are allowed only at source level 1.8 or above
        [ERROR] Line 247: Lambda expressions are allowed only at source level 1.8 or above
  [ERROR] Hint: Check the inheritance chain from your module; it may not be 
  inheriting a required module or a module may not be adding its source path 
  entries properly

我检查了 Poperties > Java Compiler,它设置为在 Java Build Path 上使用 JavaSE-1.8。 Java 构建路径有一个指向 JavaSE-1.8(Eclipse) 的 JRE 系统库。

在 Window > Preferences 中,编译器合规级别也设置为 1.8。我所有必需的运行配置都将其 JRE 执行环境设置为 JavaSE-1.8(Eclipse)。我的 eclipse.ini 文件显示它应该在 Java 1.8 中启动。

最后,我还尝试删除 gwt-unitCache 并删除项目(但不是所有文件)并重新导入它。我错过了什么?

【问题讨论】:

  • 您是否更新或重新创建了用于启动程序的运行配置?
  • 我在帖子底部说过,“我所有必要的运行配置都将其 JRE 执行环境设置为 JavaSE-1.8(Eclipse)。”不过,谢谢。
  • 看来GWT直接读取源代码(见[ERROR] Errors in 'file:.../src/...'),而不是Eclipse编译的字节码。这意味着必须更改 GWT 编译器的源代码级别。
  • howgler 一针见血。我运行了错误的 GWT 编译器...

标签: java eclipse gwt gxt eclipse-oxygen


【解决方案1】:

在你的输出中它有:sourceLevel, 1.7。 这需要是 1.8。

查看项目的 GWT 开发模式运行配置。在 JRE 部分,查看运行时 JRE 的设置。

另外,您使用的是 GWT 2.8 SDK 吗?您需要 GWT 2.8 才能使用 Java 8 语言功能,例如 lambda。进去看看:

project properties > GWT > General Settings > GWT SDK

【讨论】:

  • GWT 版本就是这样做的。我不敢相信我没想到那里看。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-20
  • 2012-02-17
  • 1970-01-01
  • 2018-03-19
  • 2019-05-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多