1

I am trying to use opencsv library http://opencsv.sourceforge.net/

How to i import it so that i can start using it with NetBeans?

I have no idea what im doing so start from the very beggining after downloading and unzipping the file.

Thanks.

0

3 Answers 3

4

Copy the jar into your project lib folder. Then right click on your project select properties. Now a window opens go to libraries->Add Jar/Folder select your jar and press OK.

Sign up to request clarification or add additional context in comments.

Comments

0

You can create new maven project and add:

    <dependency>
      <groupId>net.sf.opencsv</groupId>
      <artifactId>opencsv</artifactId>
      <version>2.0</version>
    </dependency>

To Your pom file.

//edit: I suggested it because IMO NetBeans has great maven support, and it's probably the best solution for using external libs in NetBeans. How ever I'm not sure is it right way for beginners.

Comments

0

I will just add a little explanation why adding a jar file into the library works.

A jar file is actually just a zip file, on linux you can find out by this command:

file xml-apis.jar 
# xml-apis.jar: Zip archive data, at least v1.0 to extract

There is a folder structure inside the jar file, you can list it with 7z:

7z l xml-apis.jar 

The output in this case:

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs)

Listing archive: xml-apis.jar

--
Path = xml-apis.jar
Type = zip
Physical Size = 194354

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2006-11-19 23:41:36 D....            0            0  META-INF
2006-11-19 23:41:34 .....         3577          556  META-INF/MANIFEST.MF
2006-11-19 23:41:32 D....            0            0  javax
2006-11-19 23:41:34 D....            0            0  javax/xml
2006-11-19 23:41:32 D....            0            0  javax/xml/datatype
2006-11-19 23:41:32 D....            0            0  javax/xml/namespace
2006-11-19 23:41:32 D....            0            0  javax/xml/parsers
...
2006-11-19 23:41:34 .....          713          425  org/apache/xmlcommons/Version.class
2006-11-19 23:41:32 .....          399          255  org/w3c/dom/Attr.class
2006-11-19 23:41:32 .....          100           84  org/w3c/dom/CDATASection.class
2006-11-19 23:41:32 .....          516          262  org/w3c/dom/CharacterData.class
2006-11-19 23:41:32 .....          104           88  org/w3c/dom/Comment.class
2006-11-19 23:41:32 .....          400          209  org/w3c/dom/DOMConfiguration.class
2006-11-19 23:41:34 .....          433          279  org/w3c/dom/DOMError.class
2006-11-19 23:41:34 .....          129          100  org/w3c/dom/DOMErrorHandler.class
2006-11-19 23:41:32 .....          999          558  org/w3c/dom/DOMException.class
2006-11-19 23:41:32 .....          515          220  org/w3c/dom/DOMImplementation.class

Thus having added the jar file in the classpath, when you do this in your java source code:

import org.w3c.dom.DOMImplementation;

the DOMImplementation class can be found in the jar file in the directory org/w3c/dom.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.