简体   繁体   English

无法解析为Java中的类型错误

[英]cannot resolved to a type error in java

I'm new in java, please help me to understand this. 我是Java的新手,请帮助我理解这一点。

I can see there is ReadHtml class and defined with one public method. 我可以看到有ReadHtml类,并使用一个公共方法进行了定义。 But when i put this code in ecplise, it shows red mark under WebClient with tag that "this cannot resolved to a type". 但是,当我将此代码放在ecplise中时,它在WebClient下显示带有标记“这无法解析为类型”的红色标记。 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). 将其添加到文件顶部(并阅读dsp_user的注释以供将来参考)。

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 . 如果仅使用eclipse,请参阅如何在Eclipse中导入jar

If you already added the needed jar onto your class path, you are missing the import statement. 如果您已经在类路径上添加了所需的jar,则缺少import语句。 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. 请注意,如果要从项目中构建jar,则需要某种构建工具。 If you choose to use Maven, which is very common, just read any tutorial on how to get started and manage dependencies. 如果您选择使用Maven(这很常见),则只需阅读有关如何入门和管理依赖项的任何教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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