I have Java version 1.8.111 installed and the initial error message after running mvn3 install was as below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project myfile: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.6' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.
To resolved this, I've updated my toolchains.xml to version 1.8.111 but still getting the same error. I've also tried after running mvn3 clean and successfully cleaned but still getting the same error.
Could anyone pinpoint where this version 1.6 is fetched from?
I checked JAVA_HOME already, it's set to 1.8.
Can anyone explain how maven calls Java version?
Appreciate your help.
Below is my toolchains.xml
Your application is expected to be built with JDK 1.6 and to locate it Maven is looking for definition of [ vendor='sun' version='1.6' ] within toolchains.xml in your {home}/.m2/ directory (see eg this maven guide). You just need to point to it and all should be good.
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/jdk1.6.X_XX.jdk/Contents/Home</jdkHome>
</configuration>
</toolchain>
</toolchains>
Related
I am trying to deploy a java jar to heroku with heroku maven plugin.
I am using java 11 so I have added system.properties in the root folder(where pom.xml is present) and set java.runtime.version=11. However it doesn't seem to be working !
My plugin :
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<includeTarget>false</includeTarget>
<includes>
<include>${project.build.directory}/${project.build.finalName}.jar</include>
</includes>
<processTypes>
<web>java $JAVA_OPTS -jar ${project.build.directory}/${project.build.finalName}.jar</web>
</processTypes>
</configuration>
</plugin>
When I do git push heroku master it starts build process using jdk 8.
remote: Building source:
remote:
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing Maven 3.6.2... done
remote: -----> Executing Maven
remote: $ mvn -DskipTests clean dependency:list install
Eventually build fails with error :
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project ImpactHub_bot: Fatal error compiling: invalid flag: --release ->
How do I set jdk verison to 11 ? I have also tried adding ${java.version} to configuration but it didn't help
That's exactly how you are specifying the Java version, see: https://devcenter.heroku.com/articles/java-support#specifying-a-java-version
You can specify a Java version by adding a file called
system.properties to your application.
Set a property java.runtime.version in the file:
java.runtime.version=11
I used it in my project as well and it is working.
Make sure your system.properties is saved as All Files. Furthermore it should be at the root folder of your git repo.
It might have a .txt ending. If that fails open a Support Ticket with Heroku.
After adding module-info.java files to my project my checkstyle plugin start failing with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project email: Failed during checkstyle
configuration: NoViableAltException occurred during the analysis of
file
/home/xxx/IdeaProjects/blynk-server/server/notifications/email/src/main/java/module-info.java.
unexpected token: module -> [Help 1]
I tried
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
However, it failed with:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check
(default-cli) on project blynk: Failed during checkstyle
configuration: cannot initialize module
BeforeExecutionExclusionFileFilter - Unable to instantiate
'BeforeExecutionExclusionFileFilter' class, it is also not possible to
instantiate it as
com.puppycrawl.tools.checkstyle.checks.annotation.BeforeExecutionExclusionFileFilter
What is the correct way for skipping module-info.java files during checkstyle for maven-checkstyle-plugin?
Not sure why the Checkstyle filter is not working (this reported bug seems very similar to yours and it was fixed in version 7.3.0, so maybe you need to update Checkstyle).
Anyway the Maven excludes element is also supposed to do this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/module-info.java</excludes>
</configuration>
</plugin>
More in the plugin goal documentation.
BeforeExecutionExclusionFileFilter was added in Checkstyle 7.2.
But the maven-checkstyle-plugin version 3.0.0 (which is the latest version as of 2018-04-01) uses Checkstyle 6.18 by default.
"Checkstyle" and "Checkstyle Maven Plugin" are different things and have different release cycles.
You may want to upgrade the Checkstyle version as follows:
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version> <!-- Checkstyle Plugin version -->
<!-- ... Configuration, Executions ... -->
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.8</version> <!-- Checkstyle version -->
</dependency>
</dependencies>
</plugin>
After that, BeforeExecutionExclusionFileFilter as well as other newer Checkstyle features (e.g. new checks) will be recognized.
Though this doesn't possibly qualify as an answer. Yet being too long to fit in comment, just to keep a note of the track that the maven-checkstyle-plugin is in:-
The last release of the was version 2.17 on 15-Oct-2015 which was almost 2 years back.
The current trunk of maven-plugins points to an ongoing work within the plugin in its 3.0.0-SNAPSHOT version which might mean we can soon expect a org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0 sometime in near future and which would understand the module-info.java as a class.
This doesn't align with the Java+9+-+Jigsaw doc that specifies the list of modules and plugins that are being upgraded to support JDK-9.
I am having the below issue when I run my maven build in eclipse. I saw many posts like this but i still can't solve this problem .Mine may be a little more specific, I know that my JAVA_HOME is pointed to java6, and that is because I am working on another application which uses java 6. The application in which I am running into issues uses Java 8
[ERROR] COMPILATION ERROR : [INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in: C:\Program Files\Java\jre1.8.0_92\..\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
<br>[INFO] -------------------------------------------------------------
<br>[INFO] ------------------------------------------------------------------------
<br>[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------
<br>[INFO] Total time: 11:53 min [INFO] Finished at: 2016-08-18T16:52:13+05:30
<br>[INFO] Final Memory: 11M/141M
<br>[INFO] ------------------------------------------------------------------------
<br>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project
Compilation failure [ERROR] Unable to locate the Javac Compiler in: [ERROR] C:\Program Files\Java\jre1.8.0_92\..\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).
<br>[ERROR] In most cases you can change the location of your Java [ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
How can I resolve this problem without installing java 8 as it may may make changes to my JAVA_HOME etc which would make my other application to not run. Is there a way to get the JDK folder without running the .exe (p.s I already tried the 7zip method)
Please suggest
If you have the jdk8 then you can open cmd, run the command in this window to modify the JAVA_HOME set JAVA_HOME=<jdk8 path>. This will modify the JAVA_HOME env variable only for this instance of the cmd session and not for the whole OS. Now run the maven build command from this window and it wont fail.
If you wanna run the build from eclipse, then in eclipse try going to Windows --> Preferences --> Java --> Installed JREs --> click Add button --> Sel Standard VM and click next --> put in values for 'JRE Home' as path till the jdk folder and 'JRE Name' as java8 or whatever you wish --> click Finish.
Now right click the project of you interest --> click properties --> Java Compiler --> Tick 'Enable project specific settings' --> and select 1.8 here.
If 1.8 is not visible here, go to Java Build Path --> Add Library --> JRE System Library --> Alternate JRE --> select jdk8 --> Finish
Looking at the path in that error (C:\Program Files\Java\jre1.8.0_92\..\lib\tools.jar) you've installed the Java Runtime Environment (JRE).
To compile java you need the Java Development Kit (JDK) which contains the tools the maven plugin needs.
You can change your maven-compiler-plugin configurations to your JAVA_HOME.
Just go to eclipse window->preferences->type maven->and you could see something like template click on that and look for javac compiler, just go there and change to whatever java version you have.
<configuration>
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
<source>${cursor}1.6</source>
<target>1.6</target>
</configuration>
Without java8 and without .exe file you can't go ahead with your requirement.
Hope it's useful.
from your error log it says that
[ERROR] Unable to locate the Javac Compiler in: [ERROR] C:\Program Files\Java\jre1.8.0_92\..\lib\tools.jar
paste this code in your pom.xml inside build tag and make sure you add dependencies properly and please change your java version accordingly
this will only work if you have something wrong in your pom.xml.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<jvm>${JAVA_HOME}/bin/java</jvm>
<forkMode>once</forkMode>
</configuration>
</plugin>
</plugins>
note your JAVA_HOME must point like this
C:\Program Files\Java\jdk1.8.0_65
edit
There must be various reasons like
your pom is not getting path to java home
your java home is not set
you are using jre instead of jdk in your IDE
You can download the version of the JDK without installer.
Then specify a JDK 1.8 as source and target in the compiler configuration of the pom.xml with which you have your problem. in this way you don't need changing your JAVA_HOME :
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
<fork>true</fork>
<executable>D:\jdk1.8\bin\javac</executable>
</configuration>
</plugin>
<build>
I followed steps in the below link to get the portable JDK:
http://bgasparotto.com/convert-jdk-exe-zip/
I have parent [project] pom which have the
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.4.0</version>
....
</plugin>
In subproject [childpom], I am getting this error on the first line
<?xml version="1.0" encoding="UTF-8"?>
Incompatible lifecycle mapping plugin version 1.4.0
jump to definition in parent pom.
Further env details:
IDE : Jboss jeveloper studio v9.0.0
JDK : java 8 64 bit.
MAVEN : apache-maven-3.3.3
I am new to maven, pls suggest me where I went wrong?
different eclipse depends different lots of locale jar files. so try use the relation version of the eclipse version.
you can find the version number from the installation folder. they should in features or plugins.
maybe is 1.6.2. you can try!
While running mvn install on a fragment project in Eclipse I got this error:
${fragment name} cannot be installed in this environment because its filter is not applicable.
Using Eclipse-PlatformFilter: (osgi.os=macosx) in the Manifest breaks the build.
Here's the output surrounding the key error (IDs/directory names redacted):
[INFO] Resolving dependencies of MavenProject: ${fragmentID}:4.3.0-SNAPSHOT # ${fragmentDir}/pom.xml
[INFO] {osgi.os=linux, org.eclipse.update.install.features=true, osgi.arch=x86_64, osgi.ws=gtk}
[ERROR] Cannot resolve project dependencies:
[ERROR] Problems resolving provisioning plan.:
[ERROR] ${fragment name} cannot be installed in this environment because its filter is not applicable.
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
The link (http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting) doesn't help.
I found a few similar errors on the internet (component X cannot be installed in this environment because its filter is not applicable), but they all apply to instances where it's downloaded software and there's either no solution or the solution isn't applicable to my case.
Grateful for any help!
Edit:
I found that using Eclipse-PlatformFilter: (osgi.os=macosx) in the host plugin works, and also Eclipse-PlatformFilter: (| (osgi.os=macosx) (osgi.os=linux) (osgi.os=win32) ) in the fragment works. It seems that the build goes through each environment set in an ancestor pom, and it breaks when the fragment doesn't apply for any one of those environments.... surely there's some flag I could set to prevent that?
Tycho builds for all the operating system environments configured through the POM. There is currently no way to automatically filter these environments to what is configured as Eclipse-PlatformFilter. So when building a fragment only for a certain operating system, you need to manually override the <environments> configuration from your parent POM in the POM of the fragment:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<environments>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>