Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to configure JDK for Maven

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Following are the environment details that I am using for my development.

1. OS: Windows
2. JDK: IBM 1.7
3. Maven: 3.2
4. Cygwin

I am getting following problem when I execute the my java program from Cygwin(installed on windows)



After initial analysis I found that cygwin is using JDK 1.6 though the JDK home is 1.7. When I execute mvn -version from cygwin I get following output

# mvn -version


but when I execute mvn -version from windows command prompt I get.




Is there any way to configure JDK to 1.7 (in MVN or in cygwin).

Any help on this is really appreciated.
 
Sheriff
Posts: 4870
317
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a plugin for Maven to tell it what version of Java to use when compiling. By default it tries to use JDK 5, which is almost always incorrect.

Apache: maven-compiler-plugin

For example, in my current project I have this in my pom.xml

It looks like the most recent version is 3.6.1 so you might want to use that. We're using an older version because it was configured ages ago and not touched since.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a slightly more concise way to do the same thing:
 
Suraj Jadhav
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim and Knute for your response. I have verified the pom and that is configured for JDK 1.7.

My problem is that when I execute the program with Cygwin it uses JDK 1.6 but when I execute the program from Windows command prompt it is using 1.7.

My confusion is that why it is behaving different on same machine though the JDK for JAVA_HOME is same and save Maven is used.

Only the difference is that the environment from which I am executing the program.

Do I need to set any specific environment variable for Maven before executing it from Cygwin.
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect your Cygwin setup is different than your Windows command prompt.  Cygwin uses its own PATH and maybe even its own Java install.
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic