简体   繁体   English

Java非法启动正确的项目类型

[英]Java illegal start of type in correct project

I have a Java application which I cannot launch 我有一个无法启动的Java应用程序

All error message of the type: 类型的所有错误消息:

illegal start of type
HashMap<String, Double> simScoreTable = new HashMap<>();
                                                    ^

illegal start of type
HashMap<String, Double> simScoreTable = new HashMap<>();
                                                    ^

The project requirements are Jdk 1.7 or higher. 项目要求为Jdk 1.7或更高。

My installed version is 我安装的版本是

java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)

It looks like I have some version problem. 看来我有一些版本问题。 I would appreciate if you could show me the problem. 如果您能告诉我问题,我将不胜感激。

javac 1.6.0_27

You seem to be using a 1.6 JDK but a 1.7 JRE. 您似乎使用的是1.6 JDK,但使用的是1.7 JRE。 Since you are using ubuntu, try and see what this command gives: 由于您使用的是ubuntu,请尝试查看此命令提供的内容:

dpkg --list|grep openjdk

If my reasoning is correct, you will have openjdk-6-jdk and openjdk-7-jre . 如果我的推论是正确的,那么您将拥有openjdk-6-jdkopenjdk-7-jre If this is the case, try and: 如果是这种情况,请尝试并:

sudo apt-get install openjdk-7-jdk

Normally, JDK 7 has a higher priority than JDK 6 (see update-alternatives ); 通常,JDK 7的优先级高于JDK 6(请参见update-alternatives ); so after install, you should have the correct compiler version. 因此,安装后,您应该具有正确的编译器版本。 Check again with javac -version . 使用javac -version再次检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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