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 -> sources You 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
Sometimes the problem occurs because of the incorrect version of the project bytecode.
So verify it : File -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version and set its value to 8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With