简体   繁体   中英

How to switch from Java 7 to Java 6 in Eclipse for Google App Engine?

I have developed a small application with Google Web Toolkit and would like to deploy it to the Google App Engine (GAE) server. I'm using Eclipse Juno and Java 7 by default, but when I tried to deploy to GAE, I realised that it does not support Java 7 yet. So I switched to a Java 6 JRE in the project setting (set Build Path/Libraries to "java-6-openjdk-amd64" and Java Compiler/Compiler compliance level to 1.6.

However, when I try to deploy my app via the Google Eclipse plugin, it still throws the same RuntimeException:

"The application contains Java 7 classes, but the --use_java7 flag has not been set."

Here's the complete debugging output:

Unable to update:
java.lang.RuntimeException: The application contains Java 7 classes, but the --use_java7 flag has not been set.
        at com.google.appengine.tools.admin.Application.createStagingDirectory(Application.java:576)
        at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:370)
        at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:53)
        at com.google.appengine.eclipse.core.proxy.AppEngineBridgeImpl.deploy(AppEngineBridgeImpl.java:433)
        at com.google.appengine.eclipse.core.deploy.DeployProjectJob.runInWorkspace(DeployProjectJob.java:148)
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

How can I remove the Java 7 remainders so that the Google plugin understands?

This is all running on Ubuntu 12.10 64 bit.

You are probably using your Java 7 installation to compile. In eclipse, go to Window > Preferences . In there, browse to Java > Installed JREs .

The list on the right probably only shows the jre/jdk7 in your case. You have to add your installation of Java 5 or 6 in here, and make sure that it is the "ticked" JRE.

Afterwards, use Project > Clean... , select "Clean All Projects" and make sure that "Start a build immediatly" is ticked, along with "build the entire workspace".

[Edit : this answer is not accurate for android development... When I realized that, a quck search showed that the question looks suspiciously close to Failed to deploy to Google App Engine because --use_java7 flag has not been set , the answer is probably the same.]

我最终能提供帮助的唯一方法是在Eclipse中创建一个新项目,立即切换到Java 6(构建路径,编译器,Java facet),然后复制/粘贴上一个项目中的所有文件和GAE设置。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM