I´m something new in Java Development and I will try to ask my question short and simple. Hope it works :-).
The Goal
Extend some Java classes from a given project without editing the original source files.
The Problem
It don´t work ;-)
Short description
I have two Java projects. Project A is a bigger Web project. Project B is a Web Fragment project. I want to extend some classes from Project A, but I don´t want edit the original sources. So the idea is to extend the classes in Project B.
Current state
Create Project B
I created Project B with the Eclipse Wizard
File > New > Project > Web Fragment Project
and add Project B to the Dynamic Web project, Project A
Add class to Project B
Now I copied the original Java class into Project B using the same folder structure as in Project A
Project A > WebContent > WEB-INF > src > a > b > c > MyClass.java
Project B > WebContent > WEB-INF > src > a > b > c > MyClass.java
And both classes are in the same package
package a.b.c;
So far so good. I write some test output for the console to check if the class will be overridden correctly.
Deployment
I deploy Project A and start the Tomcat Server. But my test output is not logged to the console. So I suspect, MyClass.java will be not overridden. Why?
Additional informations
Project A properties
- Project B is in Web Deployment Assembly from Project A
- I added Project B in the Projects Tab of the Java Build Path
- Under the Order and Export Tab i move Project B over Project A
Question(s)
Why will the original class in Project Anot be overridden from MyClass.java in Project B. Have i something overseen?
Thank you in advance and best regards, Daniel