How do I reference classes from another project in NetBeans?

Neetesh Dadwariya picture Neetesh Dadwariya · Jul 15, 2013 · Viewed 8.9k times · Source

I am using NetBeans 6.8.

I have a class ClassA situated in PackageA in JavaApplicationProject1.

I plan to use this class in ClassB situated in PackageB in JavaApplicationProject2 just by importing it. One option is to copy ClassA in PackageB, but I don't want to copy. How can I do this?

Answer

Michael Lang picture Michael Lang · Jul 15, 2013

Under Project Properties -> Libraries -> Compile -> Add Project you can add project dependencies. So adding JavaApplicationProject1 as a project dependency in JavaApplicationProject2 will do what you want. Details can be found in this guide