Console maven compile error - java

i was macking one of the oficial guides of spring: http://spring.io/guides/gs/maven/
But when y reach the part where i have to compile with maven this is what happens:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-maven-initial 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # gs-maven-i
nitial ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory c:\Java\WorkSpace\maven_beginer\src\m
ain\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # gs-maven-init
ial ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 2 source files to c:\Java\WorkSpace\maven_beginer\target\classe
s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.692s
[INFO] Finished at: Wed Nov 06 23:51:21 ART 2013
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
5.1:compile (default-compile) on project gs-maven-initial: Fatal error compiling
: tools.jar not found: C:\Java\jdk\..\lib\tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

Goto Windows -> Preferences
Java -> Installed JREs
Change JRE to JDK

You can resolve this issue by
Add JAVA_HOME to System variable
or Copy you java folder to c:\ from c:\program files or c:\program files (x86)
or Missing tools.jar in local repository breaks m2eclipse

Related

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources

Can any one help me? Why this is happen, and how to solve this error?
I try to run mvn clean package -DskipTests
[INFO]
[INFO] -------------------< com.hybris.hybris123:hybris123 >-------------------
[INFO] Building hybris123 1.1
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hybris123 ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # hybris123 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.723 s
[INFO] Finished at: 2022-01-13T16:41:34+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources (default-resources) on project hybris123: Cannot create resource output directory: /opt/CXCOMM210500P_0-70005661/hybris123/target/classes -> [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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My Java Home variable is /usr/lib/jvm/java-11-openjdk-amd64
And My maven variable like this :
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Please Help me

Why jdk works well but get mvn compile error

My jdk works well, but I get the error when running mvn compile
PS H:\Learning\Maven> java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
PS H:\Learning\Maven> mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.xxx:maven01 >---------------------------
[INFO] Building maven01 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # maven01 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # maven01 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\Learning\Maven\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.566 s
[INFO] Finished at: 2021-07-23T23:18:05+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven01: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
javac runs fine. After I changed jre to jdk for JAVA_HOME, I didn't reopen powershell and it kept giving me errors.

ERROR Failed to execute goal io.quarkus:quarkus-maven-plugin:1.13.2.Final:dev (default-cli) on project code-with-quarkus:

when I use the command mvn clean quarkus: dev, I get the following response from the terminal in intellij:
E:\api-hard-lot>mvn clean quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # code-with-quarkus ---
[INFO] Deleting E:\api-hard-lot\target
[INFO]
[INFO] --- quarkus-maven-plugin:1.13.2.Final:dev (default-cli) # code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 31 source files to E:\api-hard-lot\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.052 s
[INFO] Finished at: 2021-04-25T12:02:55-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.13.2.Final:dev (default-cli) on project code-with-quarkus: Fatal error
compiling: invalid target release: 11 -> [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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
'cmd' is not recognized as an internal command
or external, an operable program or a batch file.
Your project was created using JDK 11 and thus mandates JDK 11 while you are trying to build it with a JDK inferior to 11.
Either update your JDK (recommended) or adjust your project to be JDK 8 compatible (replace occurrences of 11 with 1.8 in your pom file).
thanks guys thats exactly my solution i alter to jdk 8 and
in pom
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
and
in code-with-quarkus

Build maven project with broken classes of Oracle-JDK8

When I use GraphChi-java benchmark to analysis network graph, I encounter an issue related to mvn.
Maven version and Java Version:
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T03:58:13-04:00)
Maven home: /usr/local/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-041500-lowlatency", arch: "amd64", family: "unix"
The build information is link
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
However, I get errors about
error: error while loading CharSequence, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
error: error while loading ConcurrentMap, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/util/concurrent/ConcurrentMap.class)' is broken
error: error while loading AnnotatedElement, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
These errors are weird since I think there should be no problem with java-8-oracle. Why are some class broken? How to fix it?
wxf#wxf:/home/wxf/javaPrj/graphChi/graphchi-java$ mvn assembly:assembly -DdescriptorId=jar-with-dependencies
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.graphchi:graphchi-java_2.11:jar:0.2.2
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.commons:commons-math:jar -> version 2.0 vs 2.1 # line 81, column 17
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building graphchi-java_2.11 0.2.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-assembly-plugin:2.2.2:assembly (default-cli) > package # graphchi-java_2.11 >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # graphchi-java_2.11 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/wxf/javaPrj/graphChi/graphchi-java/src/main/resources
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:compile (default) # graphchi-java_2.11 ---
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] /home/wxf/javaPrj/graphChi/graphchi-java/src/main/java:-1: info: compiling
[INFO] /home/wxf/javaPrj/graphChi/graphchi-java/src/main/scala:-1: info: compiling
[INFO] Compiling 121 source files to /home/wxf/javaPrj/graphChi/graphchi-java/target/classes at 1518718593215
[ERROR] error: error while loading CharSequence, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
[INFO] (bad constant pool tag 18 at byte 10)
[ERROR] error: error while loading ConcurrentMap, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/util/concurrent/ConcurrentMap.class)' is broken
[INFO] (bad constant pool tag 18 at byte 61)
[ERROR] error: error while loading AnnotatedElement, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
[INFO] (bad constant pool tag 18 at byte 76)
[ERROR] three errors found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.874 s
[INFO] Finished at: 2018-02-15T13:16:38-05:00
[INFO] Final Memory: 26M/1928M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.scala-tools:maven-scala-plugin:2.15.2:compile (default) on project graphchi-java_2.11: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1) -> [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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Maven with Surefire refuses to run single test method?

I've been trying to use Maven with the Surefire plugin to run some JUnit unit tests.
Following the instructions provided by Maven and the Surefire folks here: http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
My command for maven is as follows:
mvn clean -Dtest-group=regression -Dtest=TestClass#testMethod test
TestGroup is pulled from an #IfProfileValue statement and has always worked:
#IfProfileValue(name = "test-group", values = {"regression"})
However after I run the command, despite being sure that testClass has a method named testMethod(which would run if I didn't add the #testMethod to the command) my output is as follows:
~/REPOS/app: mvn clean -Dtest-group=regression -Dtest=TestClass#testmethod test
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.app:GuiAuto:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.twitter4j:twitter4j-core:jar -> version 2.2.4 vs [3.0,) # line 127, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 147, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GuiAuto 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # GuiAuto ---
[INFO] Deleting /Users/llaskin/REPOS/app/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # GuiAuto ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 92 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # GuiAuto ---
[INFO] Compiling 762 source files to /Users/llaskin/REPOS/app/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # GuiAuto ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # GuiAuto ---
[INFO] Compiling 762 source files to /Users/llaskin/REPOS/app/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # GuiAuto ---
[INFO] Surefire report directory: /Users/llaskin/REPOS/app/target/surefire-reports
[INFO] parallel='classes', perCoreThreadCount=false, threadCount=5, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.379s
[INFO] Finished at: Mon Nov 17 12:27:59 CST 2014
[INFO] Final Memory: 27M/571M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project GuiAuto: No tests were executed! (Set -DfailIfNoTests=false to ignore this 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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Maybe this is because of the bug SUREFIRE-1028 in Surefire 2.16 and 2.17. This bug is fixed in Surefire 2.18.
Can you please upgrade and tell us whether your problem is fixed with Surefire 2.18 or not.

Categories

Resources