neo4j EmbeddedNeo4j.java in maven try-with-resources error

209 views Asked by At

I'm attempting to run the first example in the Neo4j Manual chapter 32 on using Neo4j embedded in Java applications, the file is EmbeddedNeo4j.java, I'm using maven, with the proper Neo4j dependency. I'm getting a compilation error that seems to indicate I'm using Java 1.5, but everything I see tells me I'm using Java 1.7.

Here's the error:

EmbeddedNeo4j.java:[71,12] error: try-with-resources is not supported in -source 1.5

Here's why I think Maven should be using Java 1.7:

[root@cerif t02]# mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
Maven home: /opt/apache-maven-3.0.5
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_21/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.9.3-x86-linode52", arch: "i386", family: "unix"
[root@cerif t02]#

Any advice on tracking down why I'm getting this error?

1

There are 1 answers

3
ATG On

Have you told Maven to use Java 1.7 compatibility mode?

If not, try adding this to your pom.xml:

<build>
  <plugins>
     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
           <source>1.7</source>
           <target>1.7</target>
        </configuration>
     </plugin>
  </plugins>
</build>