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.