This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Giving error when compiling with ant but not showing the error in eclips Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Giving error when compiling with ant but not showing the error in eclips" Watch "Giving error when compiling with ant but not showing the error in eclips" New topic
Author

Giving error when compiling with ant but not showing the error in eclips

ravin kacha
Greenhorn

Joined: Jul 18, 2007
Posts: 22
Hi All,

I am getting across a very strange error. I have written a java file, it is getting compiled in Eclips without any error. Now I am compiling the whole package through an ANT script which is showing the below error for the code snippet while compiling

\com\holset\matrix\utils\QueryString.java - Classed method have been conflicted between two classes.

Error Prompted :-
com\holset\matrix\utils\QueryString.java:102: reference to putAll is ambiguous, both method putAll(java.util.Map<? extends K,? extends V>) in .AbstractMap<java.lang.String,capture#832 of ?> and method putAll(java.util.Map<? extends K,? extends V>) in java.util.HashMap<java.lang.String,capture#832 of ?> match
map.putAll((Map) requestMap.get("requestMap"));


can any buddy help me out to resolve this. Because this is a show stopper for me cause I am not able to create a jar because of this only.

Thanks in advance

Ravin Kacha
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Ravin,

Chances are that your ANT build and your Eclipse are using different versions of the JDK. Can you check that?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
ravin kacha
Greenhorn

Joined: Jul 18, 2007
Posts: 22
I have checked the JDK versions, both are identical.

But the question which invokes my thought process again and again is, though I am giving HashMap<K,V> as data type and creating object of the same type how can compiler get confused in AbstractMap and HashMap???
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hmm, what version of the JDK is this?
ravin kacha
Greenhorn

Joined: Jul 18, 2007
Posts: 22
JDK 1.6.0_03

is there any concern with the JDK version and ANT as such??
Vivekkk Singh
Greenhorn

Joined: Feb 20, 2009
Posts: 16
Hey ,

A generic type declaration is compiled once and for all, and turned into a single class file, just like an ordinary class or interface declaration.

Google about Genrics..It will solve the problem.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Eclipse has it's own Java compiler -- it doesn't compile using the JDK compiler.

I don't know offhand whether this is a bug in javac, or a bug in the Eclipse compiler. Here is a link to a similar-sounding bug in Sun's Java bug database which is still open for JDK 1.6, although it's apparently fixed in 1.7 and 1.5 .


[Jess in Action][AskingGoodQuestions]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Vivekkkkk Singhhhhh wrote:
Google about Genrics..It will solve the problem.


Oh, indeed. Googling "generics" will make this compiler bug go away.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Vivekkkkk Singhhhhh,

Can you please change your screen name in accordance with our Naming Policy, thanks
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Ernest Friedman-Hill wrote:Eclipse has it's own Java compiler -- it doesn't compile using the JDK compiler.

I don't know offhand whether this is a bug in javac, or a bug in the Eclipse compiler. Here is a link to a similar-sounding bug in Sun's Java bug database which is still open for JDK 1.6, although it's apparently fixed in 1.7 and 1.5 .


In addition to this, Ravin, can you try with the latest version of 1.6? (its 1.6.0_12)
Vivekkk Singh
Greenhorn

Joined: Feb 20, 2009
Posts: 16
Well I changed the Name But I think the Javaranch should change it as the I am Not able to create account with my name.So I dont think its fair enof to change my second name...lols.. ...I dont Know what kind of validation they make from First Name.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Vivek Singh at Javaranch wrote:Well I changed the Name But I think the Javaranch should change it as the I am Not able to create account with my name.So I dont think its fair enof to change my second name...lols.. ...I dont Know what kind of validation they make from First Name.


PM sent.
Vivekkk Singh
Greenhorn

Joined: Feb 20, 2009
Posts: 16
Hey here you are trying to mix a non Generic collection and generic collection..

reuestMap and map.This could be the problem because while compilation there is No error.But it may give a runtime...
Vivekkk Singh
Greenhorn

Joined: Feb 20, 2009
Posts: 16
i can give you a small example on that.


So both are valid but

Only this is valid.

Similarly in your case requestMap is too general.Where as your map is very specific.
So you are trying to put a general map to something specific.

I hope it works now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Giving error when compiling with ant but not showing the error in eclips
 
Similar Threads
Wanted: Help serializing Generic Maps!
Can we add an element in hashtable while iterating
convert hashmap <string, anytype > to hashMap<string, object>
Question in Generic Methods
how can i deal with this unchecked warning?