Reputation: 415
I have a strange problem with Eclipse Galileo.
I set Java 1.6 as my JRE. On this line of code
List templates = new ArrayList ();
I see the following error in Eclipse's problem list:
The type Collection is not generic; it cannot be parameterized with arguments
I don't have any problems with building this project with Ant.
How can I fix it? Looks like it is an Eclipse problem, but because of this error, I can't compile/publish my project from the IDE.
Upvotes: 20
Views: 72167
Reputation: 5521
I changed the import
import javax.swing.text.html.HTMLDocument.Iterator;
to
import java.util.Iterator;
then it worked for me
Upvotes: 1
Reputation: 308
Try to remove import antlr.collections.List;
and click Ctr+space to use java.util
Upvotes: 0
Reputation: 3436
It's late but still replying, might be helpful for others who are still facing the issue. I was getting exactly the same issue. The List was proper with util.List. The solution was to order the exports of the libraries. If you are using Maven or any other Libraries :
In Project -> Build Path -> Configure Build Path -> Order & Exports
Check 'JRE System Libraries' should be above 'Maven Dependencies'
This worked for me.
Upvotes: 21
Reputation: 347
for example:
public class AClass<T extends Object>
{
public HashMap<String, String> myMap;
}
if I write:
public class BClass
{
private AClass aClass = new AClass();
public void test()
{
aClass.get("test");
//return Object class
}
}
but if I write:
public class BClass
{
private AClass<?,?> aClass = new AClass<?,?>();
public void test()
{
aClass.get("test");
//return String class
}
}
Upvotes: 1
Reputation: 11
use "import java.util.List"
instead of default import "import antlr.collections.List;"
and use the JRE5 or above for generic support of collection API....
Upvotes: 1
Reputation: 31
Did you name your class list? i.e:
import java.util.*;
public class List { // can't do this, name this something else.
public static void main(String[] args) {
List<Integer> l = new ArrayList<Integer>();
}
}
Upvotes: 3
Reputation: 77
make java buildpath reference to greater than or equal to java 1.5
or you try to add the "import java.util.List" statement then you can see that
eclipse is saying it is conflicting with some other List type
for example it may be conflicting with com.lowagie.xx.xxx.List etc try to avoid these import
statements
Upvotes: 0
Reputation: 21
Hey, I removed the cryptic library and it didn't work. But then I put JRE System Library at the top, and it worked. Really weird.
Upvotes: 2
Reputation: 415
For those, who will get there from Google: the problem was with cryptix library. When I removed it from java build path the project is compiled sucesfully.
Upvotes: 6
Reputation: 11
put the entry "JRE System Library..." at the top in project, properties, java build path, order and export
Upvotes: 1
Reputation: 29680
Some ideas:
Upvotes: 0
Reputation: 114767
Sometimes it's an eclipse hiccup and eclipse -clean
plus refreshing all projects helps.
Edit
Does it change anything when you replace your code with:
java.util.List templates = new java.util.ArrayList();
or even
java.util.List<Object> templates = new java.util.ArrayList<Object>();
?
Upvotes: 1
Reputation: 1323553
What List
are you importing? (see this thread from 2006)
java.awt.List
or java.util.List
?
Because, as eclipse aptly comments, java.awt.List
is not parameterized ;)
Check also the
Other than that, there was lots of issue back in 2005 when the latest Eclipse 3.1 beta was supporting J2SE5, but this was fixed since then.
Try tyo use the latest JDK6 in your project.
Upvotes: 38