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
?

- 4,460
- 4
- 31
- 50

- 21
- 1
- 1
- 3
-
1Power of .jar will help you! – bsiamionau Mar 13 '13 at 14:25
3 Answers
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
.

- 1
- 1

- 8,756
- 2
- 35
- 53
-
Hi Bastien. I red the link but still am unclear why this is necessary. What is the purpose of Jar files and why can't the correct path be specified in the import statement? Do you have any additional readings you would recommend? I have never imported from another package (that wasn't part of the Java language) before. – Celeritas Jan 04 '17 at 09:58
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.

- 20,268
- 21
- 102
- 205
-
I think the OP doesn't want to create a new package, but to import an existing package to a new application to instantiate its classes. – Bastien Jansen Mar 13 '13 at 14:27
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

- 58
- 8