user2530452
user2530452

Reputation: 23

JSoup import not recognised in a method

I want to use JSoup for a very simple purpose: to strip character codes from some snippets of HTML text. ExStrip holds three strings, which are meant to get parsed if passed to constructor or to set methods. The import is recognised in the constructor, but not in the subsequent method:

     import org.jsoup.*;


    public class ExStrip {


    private String catalogue;
    private String title;
    private String fulltext;

    public ExStrip(String sColl, String sTit, String sFull) {   
    catalogue = Jsoup.parse(sColl).text();
    title = Jsoup.parse(sTit).text();
    fulltext = Jsoup.parse(sFull).text();
    // works fine, JSoup recognised
    }

    public void setCatalogue(String coll) {
       this.catalogue = JSoup.parse(coll).text(); 
       // cannot find symbol, symbol: variable JSoup
    }
    public void setTitle(String coll) {
       this.title = JSoup.parse(coll).text();
       // cannot find symbol, symbol: variable JSoup
    }
    public void setFull(String coll) {
       fulltext=coll;
    }
    public String getCatalogue() {
        return catalogue;
    }
    public String getTitle() {
        return title;
    }
    public String getFull() {
        return fulltext;
    }
}

I'm doing this in NetBeans. The jsoup jar file is imported properly, I think, in the project properties, and it does show up in the project. I also tried importing the JSoup libraries more precisely than a star import, which didn't help, and in any case, why would an exact same call work in one method of a class and not another?

I'd appreciate any help with this.

Upvotes: 2

Views: 621

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285405

You state:

JSoup import not recognised in a method

Your imports are actually being recognized just fine, but you need to remember that for Java, both spelling and capitalization are important.

JSoup != Jsoup

So change:

this.catalogue = JSoup.parse(coll).text(); 

to:

this.catalogue = Jsoup.parse(coll).text(); 

and make similar changes throughout your program.

Upvotes: 1

Related Questions