简体   繁体   中英

cannot resolved to a type error in java

I'm new in java, please help me to understand this.

I can see there is ReadHtml class and defined with one public method. But when i put this code in ecplise, it shows red mark under WebClient with tag that "this cannot resolved to a type". May I know what does it mean? Gone through all about method definition but couldn't find any remedy to understand this.

Can I get any help ?

public class ReadHtml {
    public static LinkedList<String> readJacksonCounty(String urlName, String pStartDate,String pFinishDate)
    {
        LinkedList<String> xmlListReturn=new LinkedList<String>();
        System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "error");
        final WebClient webClient1 = new WebClient(BrowserVersion.CHROME);
        webClient1.setJavaScriptTimeout(60000);
        webClient1.getCookieManager().setCookiesEnabled(true);//enable cookies
        webClient1.getCache().clear();

You are missing an import of this library:

import com.gargoylesoftware.htmlunit.WebClient;

Add this to the top of your file (and read dsp_user's comment for future reference).

Basically "...cannot be resolved to a type" means that type is not available on the class path. If you're just using eclipse refere to How to import a jar in Eclipse .

If you already added the needed jar onto your class path, you are missing the import statement. Imports just make it so that you dont have to use a class's fully qualified name. (you can type

 MyClass myClass;

as opposed to

 com.some.package.MyClass myClass;

if you add

 import com.some.package.MyClass;

at the top of your file.

Note that if you want to build a jar from your project you'll need some kind of build tool. If you choose to use Maven, which is very common, just read any tutorial on how to get started and manage dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM