Arshpreet kaur
Arshpreet kaur

Reputation: 21

How to import user-defined package in netbeans

I have a application whose name is javaapplication3. I want to create an object of javaapplication3 in another application whose name is javaapplication6. How do I add this user-defined package in javaapplication6?

Upvotes: 2

Views: 30642

Answers (3)

calebpitan
calebpitan

Reputation: 78

Although this question has been asked a long time ago. There was no clear answer that could solve the problem. So: To import your own jar or Java class you use Project properties in the file menustrip on netbeans. You create your library, say MyLibrary, and add classpath and jar file sources

Upvotes: 0

Bastien Jansen
Bastien Jansen

Reputation: 8836

If those packages are in the same project:

import javaapplication3.*;

If the packages are in different projects, you have to build a Jar from application 3, then add this jar as a dependency to the project application 6.

A third (and dirty) solution would be to copy paste package javaapplication3 to you new javaapplication6.

Upvotes: 5

D.R.
D.R.

Reputation: 21194

Right click on "Source PAckages" -> "New" -> "Java Package..."

enter any name you like?! :-)

Edit after first comment: You have to go to project properties -> Libraries -> Add Project and add the other project.

Upvotes: 1

Related Questions