(Eclipse Luna)
Say I have the following "Project A":
Project A
a.b.c.package1
One.java
Two.java
Three.java
a.b.c.package2
Four.java
Five.java
And I have another "Project B" that attempts to serve as an experimentation project that uses Project A as a dependency. So Project B depends upon Project A in the project settings. Project B looks like this:
Project B
x.y.z.package3
Main.java
(which then uses many of the classes in project A, and Main.java contains application main() routine).
This of course works fine. However, what if I want project B to experiment with changing a class from project A, and have it replace it entirely. Such as:
Project B
x.y.z.package3
Main.java
a.b.c.package2
Four.java <-----this is to replace the Four.java in Project A
....and have Project A's Four.java be completely ignored by everything so long as I'm "in" Project B. So if Five.java refers to Four.java, it actually is referring to Project B's Four, etc.
Can this be done?
So you will have two Four.class files in your classpath. When jvm needs a class it will use first it can find, if multiple classes with same fully qualified name on the classpath.
So if you want Project A's Five.java to refer Project B' Four.java, you have to make Project B classes to be first in the classpath.
In eclipse go to
Project B Properties > Build Path > "Order and Export"
Use Up/Down buttons to move Project B above Project A, that way ProjectB will be first in the claspath.