Friday, November 8, 2019

How To Laid Upwardly Specific Coffee Version For Maven Inward Windows?

Maven is a peachy create tool as well as most of the Java developer uses Maven to create their projects, but similar whatsoever other tool, at that spot are to a greater extent than or less intricacies which you lot necessitate to know spell using it. One of them is that Maven uses Java version from the JAVA_HOME surroundings variable as well as non the PATH surroundings variable. If you lot receive got multiple JDK installed on your machine as well as getting an Unsupported major.minor version 51.0 or Unsupported major.minor version 52.0 fault spell edifice your projection but receive got right Java version inwards PATH thus you lot may necessitate to depository fiscal establishment fit the JAVA_HOME as well as update it. If you lot don't receive got access to produce it thus you lot tin nonetheless modify JAVA_HOME using laid ascendence inwards your local vanquish as well as run the Maven's mvn ascendence to create the project

This modify volition non impact the entire machine as well as become away every bit before long every bit you lot closed the shell. I'll enjoin you lot how to that inwards this article.

Recently I got a jeopardy to move amongst QuickFIXJ, an opened upward root library to parse as well as procedure FIX messages. If you lot don't know the FIX, it stands for Financial Information Exchange protocol as well as is used heavily for Electronic trading. If you lot are interested, you lot tin larn to a greater extent than nearly the FIX inwards my serial of FIX tutorials.

I had a requirement to add together a custom FIX tag to parse incoming message as well as for that, I necessitate to extend the FIX lexicon of QuickFIXJ (like a FIX44.xml file) as well as create the JAR file. In gild to produce that I cloned the latest unloose of QuickFIX from GitHub as well as started edifice using Maven, exclusively for the create to live on failed.

I was getting "org/apache/maven/plugins/resources/ResourcesMojo : Unsupported major.minor version 51.0" fault which way Maven is using JDK 1.6 or lower to create the projection but the projection needed Java 1.7 (See my article on UnsupportedClassVersion to larn more).

I was surprised yesteryear this fault because I was certain that I am using Java 1.8, which should live on plenty to create the project. To confirm that I run next ascendence inwards the ascendence trace of piece of work window I was using to run Maven:

$ coffee -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b32)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b32, mixed mode)


And it was declaring the right Java version. Then I realized that when you lot type coffee on ascendence prompt it selection the JDK version from the PATH surroundings variable but Maven uses JAVA_HOME surroundings variable to selection the JDK version to create your projection as well as run it's a plugin.

To confirm the JAVA_HOME, I checked the surroundings variable using "env" vanquish ascendence on Windows as well as boom, it was pointing to JDK 1.6 which explains the error.

The solution was at nowadays easy, I only updated JAVA_HOME as well as it worked fine. So, only recollect that Maven doesn't purpose PATH to selection the Java version, instead, it uses JAVA_HOME variable.

If you lot are getting the Unsupported major.minor version 51.0 or Unsupported major.minor version 52.0 fault spell edifice your projection or whatsoever opened upward root projection using Maven, delight depository fiscal establishment fit the JAVA_HOME surroundings variable inwards your machine as well as modify it to JDK 1.7 or JDK 1.8 depending upon the fault you lot are getting. You tin depository fiscal establishment fit The Complete Java Masterclass to larn to a greater extent than nearly flat files as well as how Java plant inwards general.



How to specify Java Version for Maven inwards Command prompt

The solution was slow inwards my illustration but i of my readers reported that he can't modify an surroundings variable inwards his PC without elevated access or calling to Desktop support, which happens mainly on a big scheme similar Investment banks.

If you lot also stuck inwards a similar situation, don't worry. You tin nonetheless modify the JAVA_HOME surroundings variable inwards the local vanquish you lot are running the maven ascendence yesteryear using the "set" ascendence every bit shown below:

$ laid JAVA_HOME=path-to-jdk-bin-directory


The modify volition live on temporary as well as exclusively applicable to the vanquish you lot are running. It volition non impact your machine's JAVA_HOME settings as well as volition become away every bit before long every bit you lot closed the vanquish or opened upward a novel shell.

This solution is actually overnice every bit you lot don't necessitate elevated access as well as tin solve the employment immediately. Btw, if you lot desire to larn nearly Maven itself, I propose you lot accept a hold off at the Unsupported major.minor version 51.0 or Unsupported major.minor version 52.0 error spell edifice your projection or whatsoever opened upward root projection using Maven, delight depository fiscal establishment fit the JAVA_HOME surroundings variable inwards your machine as well as modify it to JDK 1.7 or JDK 1.8 depending upon the fault you lot are getting.

For example, Unsupported major.minor version 51.0 way JAVA_HOME is pointing to JDK 1.6 or lower as well as Maven using that to run it's compiler plugin to create your projection as well as that needs JDK vii or higher.  On the other mitt Unsupported major.minor version 52.0 way JAVA_HOME is pointing to Java vii or lower as well as you lot necessitate to modify it to indicate to Java 8 or higher to run Maven successfully.


Further Learning
Maven Crash Course
answer)
  • How to growth the heap size of Maven? (steps)
  • How to gear upward Maven Eclipse Dependency search non working issue? (solution)
  • How to install Maven inwards Windows 10? (steps)
  • How to create a Java projection using ANT? (article)
  • How to create or modify build.xm inwards ANT? (tutorial)
  • Top v Apache Maven Books for Free (books)
  • 10 Points nearly Maven Java Developer should know (maven)
  • 10 Maven Plugins Every Java Developers should know (plugins)
  • 6 Free Maven as well as Jenkins Courses for Java developers (courses)

  • Thanks for reading this article thus far. If you lot notice this article useful delight portion amongst your friends as well as colleagues. If you lot receive got whatsoever questions or feedback delight drib a note.

    No comments:

    Post a Comment