*
The moose likes Ant, Maven and Other Build Tools and the fly likes Why is Maven using the wrong JDK? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Why is Maven using the wrong JDK?" Watch "Why is Maven using the wrong JDK?" New topic
Author

Why is Maven using the wrong JDK?

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Hi all,
When I am trying to build my project it gives the following error.....

C:\buildarea\eSongBulk\src\main\java\com\hfa\esongbulk\service\HibernateSessionFactory.java:[24,36] generics are not supported in -source 1.3
(try -source 1.5 to enable generics)
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();

But in my Environment Variables my JAVA_HOME is set to jdk1.5.0_10. Is there any reason why maven is not seeing this? How do I make it to?

Or else can I specify the correct JDK in my pom.xml somehow?

Thanks for any help.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Like it or not, by default Maven assume that all source is 1.3 compatible. Well, at least that is what I recall reading somewhere but I am not able to locate the source. Of course the useless Maven documentation is completely silent on what the default value is. In other words, when it fires off the compiler, it uses the option "-source 1.3". If you want it to compile code that requires 1.5, you must set the source version like this:



JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Peter Johnson wrote:Like it or not, by default Maven assume that all source is 1.3 compatible. Well, at least that is what I recall reading somewhere but I am not able to locate the source. Of course the useless Maven documentation is completely silent on what the default value is. In other words, when it fires off the compiler, it uses the option "-source 1.3". If you want it to compile code that requires 1.5, you must set the source version like this:



Peter is correct and I ran into the same thing. And if you dig a little deeper you will actually find that fact stated, but Maven's documentation does leave somewhat to be desired. Use his compiler plugin settings (above) and all will be well.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Thanks guys. This worked. You guys are the best!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is Maven using the wrong JDK?