Try-with-resources are not supported at language level '6'

Answered

I am using the Ultimate version of IntelliJ.  My database refers to an SQLite JDBC adapter.  I also get the following error when using Rebuild Project from the Run menu:

error: try-with-resources is not supported in -source 6
(use -source 7 or higher to enable try-with-resources)

 

I have tried the suggestions of the following link with no success:

https://stackoverflow.com/questions/12900373/idea-javac-source-release-1-7-requires-target-release-1-7/12900859#12900859

 

I use version 10.0.1 of the OpenJDK gotten from this link:

https://www.azul.com/downloads/zulu/zulu-linux/

 

My SQLite JDBC adapter comes from:

http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.xerial%22%20AND%20a%3A%22sqlite-jdbc%22

 

How should I approach this issue?  Thank you for your time.

0
3 comments

Do you use Maven/Gradle in project?

 

Check that you have Language level set to version >= 1.7 in File | Project Structure | Modules | <module name> | Sources tab.

1

My project does rely on Maven and Gradle.  I see that changes to the "Language Levels" does work, but when I Refresh the Gradle side of my project, the Language Levels in Project Structure reset to their defaults.  Is there a way to keep the Language Levels from changing?

 

When I choose Rebuild Project from the Build menu, I still get the error:

error: try-with-resources is not supported in -source 6 (use -source 7 or higher to enable try-with-resources)

 

 

I have tried the following, but it does not fix the issue:

 

Lastly, I switched to the Oracle 10 JDK, but I receive the same results.

Again, thank you for your time.

0

In case of a Maven or gradle based project you must configure language source/target level in Maven pom.xml or Gradle build.gradle files.

Maven: http://maven.apache.org/plugins-archives/maven-compiler-plugin-3.1/examples/set-compiler-source-and-target.html

Gradle: https://stackoverflow.com/q/41017544/2000323

0

Please sign in to leave a comment.