try-with-resources is not supported in -source 1.5

This is for Hadoop eco system like HDFS, Map reduce, Hive, Hbase, Pig, sqoop,sqoop2, Avro, solr, hcatalog, impala, Oozie, Zoo Keeper and Hadoop distribution like Cloudera, Hortonwork etc.
user123
Posts: 91
Joined: Sun Aug 30, 2015 7:57 am
Contact:

try-with-resources is not supported in -source 1.5

Postby user123 » Mon Jan 29, 2018 7:34 pm

Somehow my maven project using are 1.5 after manually updating to 1.7 in eclipse.

How I can update my maven project for jre 1.7 in eclipse. my other projects are using 1.7 or 1.8 but maven always created with jre 1.5. The strange is after updating java build to 1.7 again it going to 1.5 while do update or compile the project.

Code: Select all

[WARNING] The requested profile "property-overrides" could not be activated because it does not exist.
[WARNING] The requested profile "dev" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project DQITest: Compilation failure
[ERROR] /Users/test12/Documents/workspace/DQITest/src/main/java/PrepareQuery.java:[322,6] error: try-with-resources is not supported in -source 1.5
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:


dan1234
Posts: 40
Joined: Sat Jan 27, 2018 3:56 am
Contact:

Re: try-with-resources is not supported in -source 1.5

Postby dan1234 » Mon Jan 29, 2018 7:36 pm

you can add below element in pom.xml which will force your maven project to use jre 1.7

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>


Return to “Hadoop and Big Data”

Who is online

Users browsing this forum: No registered users and 2 guests