Results 1 to 4 of 4
  1. #1
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default telling netbeans to use an already external imported library?

    Hello, I have already put an external library into netbeans via this tutorial.

    https://www.youtube.com/watch?v=vqhQY7U9Rlc

    So netbeans sees the library and is completely okay with it, however I don't understand how to tell netbeans to use that library in my code.

    for example, the library I already imported I named it "opencsv" which contains the file "opencsv-3.4.jar"

    so in Netbeans what am I supposed to put in order to have it use that library?

    I have tried
    Java Code:
    import java.opencsv-3.4;
    with no success

    I have also tried
    Java Code:
    import opencsv-3.4;
    I also tried
    Java Code:
    import opencsv;
    (since I named my library opencsv in netbeans)

    I have tried using capital letters in case I used upper case letters unknowingly which also didn't work.

    I asked my professor how to import external libraries and he said it's up to the IDE and he's more familiar with eclipse than netbeans.

    I keep googling around but I keep getting how to import the library into netbeans, which I already did. All I'm trying to do is tell netbeans to use the already imported library at the beginning of the code. Is there a link anyone could provide me with or do any of you know what I'm supposed to type in order to get netbeans to use the library which is already in there?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: telling netbeans to use an already external imported library?

    Probably you already did the library setup correctly; where you are failing is understanding how the 'import' statement works. You import classes, not libraries or packages.

    If I look at the API documentation:

    opencsv 3.5 API

    I can see that OpenCSV has a class com.opencsv.CSVReader.

    CSVReader (opencsv 3.5 API)

    So the following import statement should work:

    Java Code:
    import com.opencsv.CSVReader;
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: telling netbeans to use an already external imported library?

    Yes!! that's exactly what I needed!! Thanks!

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: telling netbeans to use an already external imported library?

    Just in case you come back: I forgot to mention that the 'import' statement has nothing to do with Netbeans, it is a standard Java language feature.

    https://docs.oracle.com/javase/tutor...e/usepkgs.html

    So rather than trying to find how "Netbeans import" works, read in your Java book how it works.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Problem with adding external library (openCv)
    By giersz2 in forum New To Java
    Replies: 1
    Last Post: 10-14-2012, 04:09 PM
  2. JNI : How to resolve dll external library dependency
    By vinaykutsa in forum Advanced Java
    Replies: 0
    Last Post: 06-02-2011, 05:12 AM
  3. external library problem
    By jperson in forum Eclipse
    Replies: 2
    Last Post: 05-17-2011, 09:25 AM
  4. External Jar Library
    By a13w in forum New To Java
    Replies: 5
    Last Post: 09-24-2009, 04:23 PM
  5. external library help
    By SIAS87 in forum Java Applets
    Replies: 0
    Last Post: 03-28-2009, 03:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •