I am migrating my code from Java 1.8 to Java 11. I have done the below change in my pom.xml
From:
<java.version>1.8</java.version>
To:
<java.version>11</java.version>
Also changed the source and target in maven compiler as per below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
When I execute the command maven install I get the below error:
[ERROR] Failed to execute goal on project store: Could not resolve dependencies for project. Could not find artifact jdk.tools:jdk.tools:jar:1.7 at specified path C:\Program Files\Java\jdk-11.0.12/../lib/tools.jar -> [Help 1]
How do I solve this error? Please help
Related
When I try to run as maven build it always give BUILD FAILURE.
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project testJPA: Fatal error compiling: invalid target release: 11 -> [Help 1]
I already tried the following things:
remove .m2 folder
reinstall eclipse
set executable on pom.xml
set build option to clean
> java -version
java version "1.8.0_261"
> echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_211
pom.xml
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
None of them worked. Any guesses?
I managed to find a solution.
I installed JDK 11 and set it at Window > Preferences > Java > Installed JREs > Add > jdk-11.0.9
Downloaded at: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
Question about maven PMD plugin.
I used to have maven pod plugin version 3.12.0
Very happy with this plugin, it was configured that way, everything was working fine.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<targetDirectory>.out/reports/pmd</targetDirectory>
<outputDirectory>target/reports/pmd</outputDirectory>
</configuration>
</plugin>
However, I wanted to upgrade to the newest version 3.13.0 and I am now facing this issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<targetDirectory>.out/reports/pmd</targetDirectory>
<outputDirectory>target/reports/pmd</outputDirectory>
</configuration>
</plugin>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd (default-cli) on project my-project: Execution default-cli of goal org.apache.maven.plugins:maven-pmd-plugin:3.13.0:pmd failed: org.apache.maven.reporting.MavenReportException: /workspace/my-project/.out/reports/pmd/pmd.xml (No such file or directory) -> [Help 1]
This is literally a one character change. The 3.12 version is working perfectly fine, while with 3.13.0, it is failing 100% reproducible.
May I ask what is the issue please?
This is now fixed with version 3.14.0 of the same plugin by PMD team.
i tried build on jenkins simple project with maven , but i getting this error and i don't inderstand what's the issue
enter code here
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: Source option 6 is no longer supported. Use 7 or later.
[ERROR] error: Target option 6 is no longer supported. Use 7 or later.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-
compile) on project server: Compilation failure: Compilation failure:
As the error clearly states maven-compiler-plugin should be configured with java 7 or higher version.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Also update maven-compiler-plugin as 2.3.2 is really old. check this for further explanation Maven Compilation Error: (use -source 7 or higher to enable diamond operator)
You can solve it in 3 ways
Upgrade to JDK7 or JDK8 (meh)
Use maven-compiler-plugin version or later, because
Indicate to the maven-compiler-plugin to use source level 7 and target 7
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
or
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Running:
mvn install
Getting this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:2.5.1:compile (default-compile) on project 1: Fatal error
compiling:
tools.jar not found: C:\Program Files\Java\jre1.8.0_131\..\lib\tools.jar ->
[Help 1]
Area of POM file error:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
When I look at C:\Program Files\Java I'm not seeing tools.jar under JRE lib folder. I see it under JDK lib folder
You are using a JRE, please use a JDK compile your code
How to set a java compiler in Netbeans
I code Java 7 on Java 8 JDK
When I run
mvn clean install
it show error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project foo: Compilation failure: Compilation failure:
[ERROR] /E:/bar/XmlUtils.java:[9,44] package com.sun.xml.internal.bind.marshaller does not exist
[ERROR] /E:/bar/XmlUtils.java:[11,34] cannot find symbol
[ERROR] symbol: class CharacterEscapeHandler
[ERROR] /E:/.../FooServiceImpl.java:[106,44] package com.sun.xml.internal.bind.marshall
This is line of code make error
CharacterEscapeHandler.class.getName()
Maven can't find
import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
Maven can't find CharacterEscapeHandle. How to fix it?
but when I build, package, run by Eclipse Neon, no problem. How to fix it?
Normally you should not use any code from package com.sun.xml.internal. And this fails intentionally. Here are more details: https://bugs.java.com/bugdatabase/view_bug.do;jsessionid=1711ee4eae3ff10565fc7a212018?bug_id=6778491
This is temporary solution
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>rt.jar</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<fork>true</fork>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Maven builds success.