Reputation: 63
Trying to import the "custom" library "Htmlunit" in my project. I use the IDE Netbeans and have done the following:
I then want to import the jar "htmlunit-2.15" but Netbeans tell me the following:
'.' expected
I have tried the following formatting:
import htmluni-2.15;
import htmlunit-2.15.*;
import Htmlunit;
import Htmlunit.*;
I have read other threads here, but do not understand to the fullest how I accomplish this.
Image: [http://s8.postimg.org/7ru7csh5h/import.png][1]
Upvotes: 1
Views: 188
Reputation: 751
Create new project Maven->Java Appliacation. Find file pom.xml, and add this
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
Maven automatically download the library and add them to project.
Upvotes: 0
Reputation: 772
It doesn't work that way, you import in your code actual classes, not jars. I suggest you reading more about classpath, since it's a basic topic.
Probably you need to open the jar archive and see it's internal directory structure. When a class you are interested in a class is located, say, under file.jar -> com/example/Utils.class, you need to import it using:
import com.example.Utils
Upvotes: 3