即使我使用的是Java 8,也无法使用字符串?

时间:2016-12-24 02:36:49

标签: java maven

很抱歉,我不得不问这个问题很简单。我正在使用安装了Java 8的OSX和maven。但我无法使用字符串安装代码以防万一。你能指出什么是错的吗?

mvn -version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/apache-maven-3.3.9
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Default locale: zh_TW, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.2", arch: "x86_64", family: "mac"

代码错误消息

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/Briancheung/Documents/projects/webcompiler/dev/parser/src/main/java/project/Preference.java:[40,23] 
strings in switch are not supported in -source 1.5
 (use -source 7 or higher to enable strings in switch)
[INFO] 1 error

似乎maven没有使用我安装的Java 8 JDK。感谢您的回复。

java -version

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

javac -version

javac 1.8.0_45

0 个答案:

没有答案