views:

60

answers:

3

Hi, i want to access or get the class which is present in different project.How can i do that?Help

Actually the using reflections i want to access a class from different package. Class class="class from another project"

+1  A: 

Just add the other project (or its JAR file) to your current project's classpath. That should make all of classes from the other project visible in your current project.

For more detail you will have to give more information about the particulars of your setup.

Edit:

No reflection should be needed given the contents of your question but tagging the question "reflection" makes me wonder if perhaps I've misunderstood it.

Kris
A: 

Hi Steven,

do you really need java reflection? in your case, classpath para doesn't help?

put /foo/bar/MyClass.class in to your classpath.

I hope I understood your question correctly.

Kent
+1  A: 

You can use Eclipse IDE which has a facility to add the Project as a dependeny, by which you can use the class you want to access.

You can do that by right clicking on the project and select Buildpath configuration and in that select Projects tab and the project which has a class which you want to use.

GK
@gurukulki-thanks got it
Steven
but how can i do it programatically.I want to write code which does that.How should i do that?
Steven
I think you can do that by creating jar of that project and adding it to class path before you run your application.
GK