问题描述
我正在尝试运行我的 JSQL 解析器类,但我收到 Error: java: invalid source release 1.9
.
我尝试关注
代码
package cs4321.project2;导入 java.io.FileReader;导入 net.sf.jsqlparser.parser.CCJSqlParser;导入 net.sf.jsqlparser.statement.Statement;导入 net.sf.jsqlparser.statement.select.Select;公共类解析器{private static final String queriesFile = "resources/input/queries.sql";公共静态无效主(字符串 [] args){尝试 {CCJSqlParser 解析器 = new CCJSqlParser(new FileReader(queriesFile));声明声明;while ((statement = parser.Statement()) != null) {System.out.println("读取语句:" + 语句);选择选择=(选择)语句;System.out.println("选择主体是" + select.getSelectBody());}} 捕获(异常 e){System.err.println("解析时发生异常");e.printStackTrace();}}}
选择项目,然后 File > ProjectStructure > ProjectSettings > Modules -> sources您可能将语言级别设置为 9:
只需将其更改为 8(或您需要的任何值)即可.
此外,在项目设置 > 项目下检查上述相同的语言级别设置
I'm trying to run my JSQL parser class, but I'm getting Error: java: invalid source release 1.9
.
I tried to following this answer. I changed File> Build,Execution,Deployment> Java Compiler> Project bytecode version: 1.8. However, I can't change the Module language level and Project language level to 1.8 because there's not option for that. I still get the same error below.
Error
Code
package cs4321.project2;
import java.io.FileReader;
import net.sf.jsqlparser.parser.CCJSqlParser;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.select.Select;
public class Parser {
private static final String queriesFile = "resources/input/queries.sql";
public static void main(String[] args) {
try {
CCJSqlParser parser = new CCJSqlParser(new FileReader(queriesFile));
Statement statement;
while ((statement = parser.Statement()) != null) {
System.out.println("Read statement: " + statement);
Select select = (Select) statement;
System.out.println("Select body is " + select.getSelectBody());
}
} catch (Exception e) {
System.err.println("Exception occurred during parsing");
e.printStackTrace();
}
}
}
Select the project, then File > ProjectStructure > ProjectSettings > Modules -> sourcesYou probably have the Language Level set at 9:
Just change it to 8 (or whatever you need) and you're set to go.
Also, check the same Language Level settings mentioned above, under Project Settings > Project
这篇关于intellij 想法 - 错误:java:源代码版本 1.9 无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!