Search code examples
javahtmlunit

HTML unit basics failing


The very basic example from HTMLUnit the website is not compiling in Java:

final WebClient webClient = new WebClient();
final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");

I get an error on the page variable of: Type mismatch: cannot convert from Page to HtmlPage. I don't understand why this is occuring I have all the jar files and have the correct imports!


Solution

  • Either you're using an older version of HtmlUnit, that hasn't been made generic, or you're using JDK1.4 or older. The last version is the version 2.9. Check the version you're using.