Adding Java Libraries to Netbeans 6.9

Netbean 6.9 ships with many Java libraries such as Ant, Hibernate and Junit just to mention a few. Undoubtedly There will be libraries that you need for your projects that are not included with the Netbeans distribution that you will want to Netbeans. This document will detail how to add Java libraries to Netbeans.

In this example we will add the Oracle 11gR2 JDBC drivers. Netbeans 6.9 includes JDBC drivers for MySQL, PostgreSQL but not Oracle. In order to use the Oracle JDBC drivers you will have to add them to Netbeans. The Oracle JDBC drivers are included with the Oracle Client and Database install or can be downloaded separately from the Oracle Technology Network (OTN).

Start up Netbeans and bring up the Library Manager which is found under the Tools menu.

The Library Manager is where you can add, modify, or delete libraries in Netbeans.

Click the New Library… button to start the process of adding the Oracle JDBC drivers.

Provide a name for the library. In this example we chose the name Oracle11gR2_JDBC. Library names cannot contain spaces. Next choose the library type. There are two library types to choose from. Class Libraries and Server Libraries. Server Libraries are application or web application libraries and Class Libraries are libraries are outside of the Java standard libraries such JDBC drivers along with any libraries that you might create. Choose Class Libraries as the Library Type and click the OK button.

You will now be taken back to the Library Manager dialog where you can add the location for the JDBC driver. There are three tabs in which you can use to set locations: Classpaths, Sources, and JavaDocs.

Classpaths Tab– Lists the jar files referenced by the library. Netbeans adds all referenced JAR files to the projects class path.
Sources Tab– The java source library is parsed by the code completion manager and is available to the Go To Source feature of the editor.
Java Docs Tab– The Javadoc library is parsed by the code completion manager and Javadoc library is available to the editor.

On the Classpaths Tab click the Add JAR/Folder… button. Browse to the location in which the JDBC driver is installed.

The Oracle 11gR2 driver includes JDBC drivers for both the 1.5 (ojdbc5.jar) and 1.6 (ojdbc6.jar) JDK. If your version of Netbeans 6.9 included the Java JDK then you have a 1.6 JDK and can select the ojdbc6.jar JDBC driver. Click the Add JAR/Folder button to continue.

Now that we have added the Oracle 11gR2 JDBC driver to the Library Manager we can now add the JDBC driver to a project. Right click the Libraries folder in the Project Navigator and select Add Library…

On the Add Library dialog select the Oracle JDBC driver

Click the Add Library button.

Once the library is added to the project code that depended on the library no longer shows an error and code completion is now available for Classes defined in the library

Now you are ready to connect an Oracle Database using JDBC and you now know how to add new libraries to Netbeans.

13 thoughts on “Adding Java Libraries to Netbeans 6.9”

  1. I need oracle 10g and (net beans 7.0) tutorial and eBook

    connect oracle 10g to net beans 7.0
    create database with java net beans and oracle

    thanks

  2. I’m using Netbeans 6.9 and I’ve followed the above to add a stand-alone jar.
    However, when I right click on the Libraries in a project, there is no ‘Add Library’.
    There is Add Dependency, but I can’t navigate to the library I created to hold my stand-alone jar.
    Any suggestions

  3. Hello Geoff,

    What type of project are you using? I am unable to recreate the issue you are experiencing. The closest I can get is when using a Java Project with Existing Sources. With that project, right clicking Libraries brings up a context menu and the Add Library is grayed out along with the other options.

    Eric Jenkinson

  4. I added library successfully but when I built a jar and execute it ; it shows error , like how will the program know where to find its “external” library.

  5. Hello someone pls help me! I have a project am trying to rebuild.the project contains icons and images but when i run the program, the images don’t appear in the output, and an error messages like this appears “Error Loading Theme:java.lang.ClassNotFoundException: com.birosoft.liquid.LiquidLookAndFeel” But in the project, i have a folder named ‘com’

  6. hi sir,iam using net beans 6.7 version,jdk 1.6 and oracle 10 g xe iam writing jsp code,its properly running but they dont connect oracle how to connect oracle 10 g pls reply

    ..:: Welcome to IGI Switch ::..

    COMPANY NAME:INFOTECH GLOBAL INDIA LIMITED

    PROJECT NAME:DEVELOPER PERFORMANCE TRACKER

    Analysis Engineers Information

    Analysis_enginer
    Id
    First_Name
    Last_Name
    Sex
    Age
    Designation
    Role

    some errors are occuring

    HTTP Status 500 –

    ——————————————————————————–

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception
    org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

    root cause
    javax.servlet.ServletException: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.ShowReport_jsp._jspService(ShowReport_jsp.java:173)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

    root cause
    java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:414)
    oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
    oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    java.sql.DriverManager.getConnection(DriverManager.java:582)
    java.sql.DriverManager.getConnection(DriverManager.java:185)
    org.apache.jsp.ShowReport_jsp._jspService(ShowReport_jsp.java:108)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

    ——————————————————————————–

    Apache Tomcat/6.0.18

  7. Hi, what if i dont have an open project to add the library to?

    Example, if i use only the services tab>databases>add new…

    it says …. not found in java.library.path…

  8. I am very happy after read your tutorial, finally i got right place where right answers will come. It’s working perfectly. i have been struggling from 2 days for connecting oracle database in netbeans ide. i really thank u very much sir.

  9. Thank you!
    I am using Portable Netbeans 8.1, and it does not appear to have ojdbc readily available, but I do have the Oracle client installed, and was able to find where the jar was hidden.
    Following your instructions was easy, once the jar was found, and adding the library worked perfectly.
    I really appreciate your very clear steps.

Leave a Reply

Your email address will not be published. Required fields are marked *