edjm
edjm

Reputation: 5472

Maven where is it looking for the JDK?

4th time typing this message up as this crappy machine I am to use crashes randomly throughout the day. Gotta love it.

My development environment JAVA_HOME is set to "c:jdk1.7.0_45" and in the POM I have the following

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
  <configuration>
    <verbose>true</verbose>
    <fork>true</fork>
    <executable>${JAVA_HOME}\jdk1.7.0_45\bin\javac</executable>
    <compilerVersion>1.7</compilerVersion>
  <configuration>
</plugin>

but have also tried

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

So Why do I get the error: multi-catch statement is not supported in -source 1.5? I don't see anything that references 1.5.

Also, I am not clear on what the source and target are exactly am only assuming things, same for what maven-compiler-plugin is to stand for.

Any straight forward answers to these questions would be greatly appreciated as I'm new and not aware to go read up on the section I don't know about because what I'm working on I don't know what it's called nor what I am to be asking what I am to be looking up. Nobody in house has a clue either as to how to use Maven. Appreciate any guidance in this painful environment.

===========================

The following is how I had to have it in order for the default of 1.5 not to execute. Changed the JAVA_HOME to the JDK 1.7 path.

<configuration>
    <forceJavacCompilerUse>true</forceJavacCompilerUse>
    <source>1.7</source>
    <target>1.7</target>
</configuration>

However, other projects that require the 1.6 are now broken. What a horrible setup.

Upvotes: 1

Views: 137

Answers (2)

Kalpesh Soni
Kalpesh Soni

Reputation: 7257

try using

<properties>
    <maven.compiler.target>1.7</maven.compiler.target>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.test.skip>true</maven.test.skip>
</properties>

Upvotes: 1

Shailendra
Shailendra

Reputation: 9102

For maven compiler plugin, as explained here

the default source setting is 1.5 and the default target setting is 1.5

Also as mentioned in the link you can try the configuration "forceJavacCompilerUse"

Upvotes: 1

Related Questions