Web Crawler

P

Paul Morrison

Hi

I got this web crawler from the Sun website
http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java,
but when trying to compile it, I get the following errors:

WebCrawler.java:16: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List in java.awt match
List listMatches;
^
WebCrawler.java:76: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List in java.awt match
listMatches = new List(10);
^
WebCrawler.java:76: java.util.List is abstract; cannot be instantiated
listMatches = new List(10);
^
WebCrawler.java:77: cannot find symbol
symbol : method add(java.lang.String,java.util.List)
location: class java.awt.Panel
panelListCurrent.add("North", listMatches);
^
WebCrawler.java:207: cannot find symbol
symbol : method removeAll()
location: interface java.util.List
listMatches.removeAll();
^

Could this be because I am running a newer version of Java than this was
made of? Ive tried changing the type of listMatches to java.util.List, but
that just creates more problems.

Any help would be much appreciated.
 
R

Roedy Green

WebCrawler.java:16: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List in java.awt match
List listMatches;
^

sounds like you imported both java.util.List and java.awt.List.

It does not know which one you mean. You have to fully quality it is
either.

java.awt.List listMatches;
or
java.util.List listMatches;

The problem could have come from a general import java.awt.*. Use
Eclipse or other IDE to split that into specific includes.
 
A

Andrew Thompson

Paul said:
Hi

I got this web crawler from the Sun website
http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java,
but when trying to compile it, I get the following errors:

WebCrawler.java:16: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List

What Roedy said (especially about making explicit imports) +
....
..Ive tried changing the type of listMatches to java.util.List,

...that's the wrong one. It is after an java.awt.List in that code.

Also, if you're using 1.5, it should show a 'deprecated' warning,
that is because of

'f.show();'

...update that to..

'f.setVisible(true);'

...and the code should be 'OK to go'.

I'm not sure if Roedy mentioned, but he has a wonderful collection
of 'quick help' on all manner of compilation and run time errors
at his site, you can find them LINKED from the bottom of the
section here..
<http://www.physci.org/codes/javafaq.jsp#exact>

...also, a better group for beginner programmers might be..
<http://www.physci.org/codes/javafaq.jsp#cljh>

HTH
 
Joined
Jun 30, 2012
Messages
1
Reaction score
0
Hi, my solution is

Hi

I got this web crawler from the Sun website
http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java,
but when trying to compile it, I get the following errors:

WebCrawler.java:16: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List in java.awt match
List listMatches;
^
WebCrawler.java:76: reference to List is ambiguous, both class
java.util.List in java.util and class java.awt.List in java.awt match
listMatches = new List(10);
^
WebCrawler.java:76: java.util.List is abstract; cannot be instantiated
listMatches = new List(10);
^
WebCrawler.java:77: cannot find symbol
symbol : method add(java.lang.String,java.util.List)
location: class java.awt.Panel
panelListCurrent.add("North", listMatches);
^
WebCrawler.java:207: cannot find symbol
symbol : method removeAll()
location: interface java.util.List
listMatches.removeAll();
^

Could this be because I am running a newer version of Java than this was
made of? Ive tried changing the type of listMatches to java.util.List, but
that just creates more problems.

Any help would be much appreciated.

--
Paul


So, i have the same problem, and i found a little solution :

change this line16 "List listMatches;" with this one : "java.awt.List listMatches;"
and
change the line77 "listMatches = new List(10);" with : "listMatches = new java.awt.List(10);"


thats will work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top