Lexy Yang
Lexy Yang

Reputation: 21

Error when using Jsoup in Eclipse

I downloaded the .jar Jsoup file from jsoup.org/download. I then ran eclipse and imported the .jar files into a java project. However, I keep getting an error when I type

import org.jsoup.nodes.*;

I want to use the Document class in that file.

I made sure the syntax was correct and everything, but the error won't go away. Anyone know what the problem could be?

Upvotes: 0

Views: 6239

Answers (2)

Indrek Kõue
Indrek Kõue

Reputation: 6449

Right click on project in Eclipse > Properties > Java Build Path > Add Jar > select the jar from your project which you imported before > ok

Upvotes: 0

BalusC
BalusC

Reputation: 1108537

You need to add the JAR file to project's build path. Drop the JAR in the project's root folder or some /lib folder, rightclick the JAR file and then choose Build Path > Add to Build Path.


Unrelated to the concrete problem, using wildcard imports is not the best practice. Rather specify the imports separately, or just let Eclipse autocomplete it by entering Ctrl+Space after typing Document in the code.

Upvotes: 1

Related Questions