1

Trying to import the "custom" library "Htmlunit" in my project. I use the IDE Netbeans and have done the following:

  1. Right click "Library"
  2. Clicked "Add Library"
  3. Created the Library and added it

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]

user3751508
  • 63
  • 2
  • 7

2 Answers2

3

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
meliniak
  • 762
  • 1
  • 9
  • 16
0

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.

kris14an
  • 741
  • 7
  • 24