---skippable part---
Hi all, first time here and hopefully I'm not writing a clone of anything else. I spent days looking for cases like mine and all the things I tried failed to work, or couldn't simply find the correct solution for me.
I'm trying to use Maven on another student's project I'm working on (have to continue what he already did) for a school project, on a pc with Ubuntu 14.04. I'm in my project directory downloaded from github and I need to create a .war file and use that for Tomcat.
I was following a guide of that student, and probably I'm a little confused on what to do.
---tl:dr i need help---
So when I launch mvn -version, I get this:
Java version: 1.7.0_101, vendor: Oracle Corporation Java home:
/usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: it_IT, platform
encoding: UTF-8 OS name: "linux", version: "3.19.0-58-generic", arch:
"amd64", family: "unix"
Few days ago I had problems with $JAVA_HOME environment variable and probably solved it managing the /etc/environment file, in fact I don't get any error about this. Now when I do a mvn package I get
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building GWT Maven Archetype 2.6.0-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce
(enforce-versions) # webprotege --- [INFO] [INFO] ---
gwt-maven-plugin:2.7.0:generateAsync (default) # webprotege --- [INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) #
webprotege --- [INFO] Source directory:
/home/wapaolo/Documenti/data/webprotege/webprotege/target/generated-sources/gwt
added. [INFO] [INFO] --- maven-resources-plugin:2.3:resources
(default-resources) # webprotege --- [INFO] Using 'UTF-8' encoding to
copy filtered resources. [INFO] Copying 10 resources [INFO] [INFO]
--- maven-compiler-plugin:2.3.2:compile (default-compile) # webprotege --- [INFO] Compiling 1744 source files to /home/wapaolo/Documenti/data/webprotege/webprotege/target/webprotege-2.6.0-SNAPSHOT/WEB-INF/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: javac: invalid
target release: 1.8 Usage: javac use -help
for a list of possible options
[INFO] 1 error [INFO]
------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 5.241s [INFO] Finished at: Mon May 09 16:54:04 CEST
2016 [INFO] Final Memory: 18M/295M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project webprotege: Compilation failure [ERROR]
Failure executing javac, but could not parse the error: [ERROR] javac:
invalid target release: 1.8 [ERROR] Usage: javac [ERROR] use -help for a list of possible options [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
So what should I do to proceed now? I've no clue..
Your maven project wants java 1.8 but your compiler is 1.7. Look in the pom.xml file for something like
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
and change that to 1.7 OR download the 1.8 jdk.
Related
--- maven-clean-plugin:3.1.0:clean (default-clean) # Homework5 ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # Homework5 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/vintage/eclipse-workspace/Homework5/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # Homework5 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/vintage/eclipse-workspace/Homework5/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: 2.281 s
[INFO] Finished at: 2022-03-19T00:14:48-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project Homework5: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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
Unable to run my code for a homework assignment. It says that " No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK" but I'm unsure on how to fix that issue.
Running Mac OSX Monterey 12.2
Eclipse IDE 2022-03
Tomcat Apache 9
I switched from windows to MacBook Air which is having M1 chip. I installed java and added the environment variables in .zprofile as follows
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH="${JAVA_HOME}/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}"
But when I run echo $JAVA_HOME, I see the output as /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home instead of /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home. I am not able to check if variable is set to JDK or JRE.
From Intellij, when I run mvn test clean, error is shown as,
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.example:SampleProject >----------------------
[INFO] Building SampleProject 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SampleProject ---
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # SampleProject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SampleProject ---
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/moengage/IdeaProjects/SampleProject/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # SampleProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/moengage/IdeaProjects/SampleProject/target/test-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: 1.392 s
[INFO] Finished at: 2021-11-18T13:20:33+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project SampleProject: 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:
Note: I checked others' questions as well and none of them were helpful. Can someone please help me in resolving this.
I am trying to execute the maven project from java main
Please refer the code below.
public static void main(String args[]) throws MavenInvocationException
{
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile( new File( "C:\\Users\\DPKA764\\git\\be.axa.testautomation.phoenixiard\\pom.xml" ) );
request.setGoals( Arrays.asList( "clean", "install" ) );
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File("C:\\J\\apache-maven-3.5.3"));
System.out.println(""+invoker.getMavenHome());
invoker.execute( request );
System.out.println("suites are completed");
}
and when i execute the code as 'Java Application' it is throwing the following error.
[WARN] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< be.axa.PhoenixIARD:PhoenixIARD >-------------------
[INFO] Building git-training 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # PhoenixIARD ---
[INFO] Deleting C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target
[INFO]
[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) # PhoenixIARD ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # PhoenixIARD ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # PhoenixIARD ---
[INFO] Compiling 57 source files to C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.885 s
[INFO] Finished at: 2020-02-03T18:24:34+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "metadata" 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 PhoenixIARD: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[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
but when i execute the project directly as Maven Test It will run fine.Please suggest any changes i have to do
I try to generate a new project in an empty folder on Windows 10. I am sure the directory is EMPTY. Reference: Error when creating a new maven project
C:\Projects\Java\>mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: C:\Program Files\apache-maven-3.6.0\bin\..
Java version: 11.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
C:\Projects\Java>mvn -B archetype:generate -DarchetypeGroupdId=org.apache.maven.archetypes -DgroupdId=com.mycompany.app -DartifactId=HelloWorld -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources # standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Property groupId is missing. Add -DgroupId=someValue
[WARNING] Property package is missing. Add -Dpackage=someValue
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.625 s
[INFO] Finished at: 2018-11-05T10:43:49+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
[ERROR] Property groupId is missing.
[ERROR] Property package is missing.
[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
Fixed. It was due to typo: "-DgroupId".
I'm having some difficulty getting Travis CI running. I though my .yml file was set correctly to use java 8, but I'm getting errors that say otherwise.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/local/maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-042stab105.14", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HonestMistakesWPINav 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # HonestMistakesWPINav ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # HonestMistakesWPINav ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 24 source files to /home/travis/build/theflanman/HonestMistakesWPINav/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/travis/build/theflanman/HonestMistakesWPINav/src/main/gui/DevGUIFront.java:[214,92] lambda expressions are not supported in -source 1.5
(use -source 8 or higher to enable lambda expressions)
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.506 s
[INFO] Finished at: 2015-11-24T18:19:53+00:00
[INFO] Final Memory: 9M/134M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project HonestMistakesWPINav: Compilation failure
[ERROR] /home/travis/build/theflanman/HonestMistakesWPINav/src/main/gui/DevGUIFront.java:[214,92] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[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
As far as I can tell, maven is recognizing that I'm using java 8, but travis is compiling in 1.5. I can't find anything anywhere about how to change that, and any help would be appreciated.
What does your travis.yml look like?
These are the first three lines of mine and this works fine for me (I'm using gradle instead of maven)
language: java
jdk:
- oraclejdk8
You're going to have to provide more information for anyone to help with this one.
For reference this is my full travis.yml for reference.
I resolved a similar problem adding these two lines on my .travis.yml file:
install: mvn install -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8 -DskipTests=true
script: mvn test -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8
Or you can indicate which JDK version is used during compilation via your POM.xml:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Both approaches work for me.