How to import java classes from other projects in NetBeans 6.8?

John R Doner picture John R Doner · Jan 16, 2010 · Viewed 56.1k times · Source

I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.

I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.

Is there a nice direct way to do this from the NetBeans interface?

Thanks for any help on this.

Answer

Vincent Ramdhanie picture Vincent Ramdhanie · Jan 16, 2010

In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.