GAE getting started in Java, Eclipse Indigo - can't compile as 1.6

﹥>﹥吖頭↗ 提交于 2019-11-30 16:13:06

I had the same problem. I was able to resolve by using the Navigator view and editing the .settings/org.eclipse.wst.common.project.facet.core.xml, changing to:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <installed facet="java" version="1.6"/>
</faceted-project>

After this change, the error went away and I could successfully run the GWT project in DevMode using jre1.7 but java 1.6 compliance level.

It really seems there should be a way to edit this java facet via project configuration, but I couldn't find it in Juno.

The answer, at least in my case, seems to be that if your Eclipse default compiler level is set to 1.7 when you create the Web Application then you can't switch it down to 1.6 successfully.

Example 1: Using JRE 1.6

  1. In eclipse set Preferences->Java->Installed JREs to jdk 1.6.0_32
  2. Set Preferences->Java->Compiler to compliance level 1.6
  3. Use google plugin to create "New Web Application"
  4. Run it locally - success
  5. Deploy to app engine, run remotely - success

Example 2: Using JRE 1.7

  1. In eclipse set Preferences->Java->Installed JREs to jdk 1.7.0_04
  2. Set Preferences->Java->Compiler to compliance level 1.7
  3. Use google plugin to create "New Web Application"
  4. Run it locally - success
  5. Upload to app engine - failure (Unsupported major.minor version 51.0)
  6. In eclipse set Preferences->Java->Compiler to compliance level 1.6 - failure (won't compile locally (Java compiler level does not match the version of the installed Java project facet).

Solution:

Before using the google plugin to create the Web Application, switch the JRE and compiler level to 1.6 (as seen in example 1).

If your project already exists, then hopefully you haven't got too far with it and can create it again.

After fighting this issue for a few hours, deleting my nocache.js in the war folder was the final piece of the puzzle.

Contrary to the answer above, I was able to succesfully downgrade to compliance level 1.6 after creating the application in 1.7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!