1

I have two projects, project1 and project2 for simplicity's matter. Project1 has package my.proj1 in it, that contains class myclass.

What is the correct sequence of actions to take for creating object my.proj1.myClass in one of the classes of project2?

I've tried adding project1 as reference, but for some reason that doesn't allow me to import classes from my.proj1 pakage.

1
  • Your project looks like a Maven project, the problem may be in pom.xml of the main project Commented Jun 10, 2011 at 18:39

2 Answers 2

5

Click on your current project, go to Properties, then Libraries, and then you should see one of the options as "Add Project". (I haven't actually tried to see if it works.)

Sign up to request clarification or add additional context in comments.

8 Comments

That's what i have done initially. To my dismay, that didn't help. Although in project view of project2 i have project1 and all its packages, NetBeans continues to claim those packages do not exist when i attempt to import them.
Maybe when you choose "Add Project", it's not the main project directory you must choose, but the base of "my.proj1" (source or compiled class directory). I noticed that you can navigate the directories when adding a project.
See this other post; you can import the jar file from "my.proj1" if nothing else works (but you need to make sure it is up to date when modifying both projects at the same time).
See also this Oracle blog. It seems that just by choosing the other project in "Add Project", its .jar will be included as a dependency. Maybe your "my.proj1" does not yet have a .jar. And it seems that if you recompile your main project, "my.proj1" is also recompiled if needed.
Have you tried also including directly "roster2-0.1.jar" (not as Add Project, but Add Jar)? You might not have automatic updating that way however.
|
0

You type -(class name)space (object name) equals new (class name); now you can access components of class by object name like suppose u have 1 component like void input() (object name).input:

1 Comment

I think the OP was having classpath issues -- the accepted answer already solved his problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.