Working with Identical Package Names in Maven/Netbeans

Dear Experts:

I have a maven project with three modules:
1) BL or my business layer stuff which is all new
2) OVERRIDE for stuff I want to modified from my original software
3) CORE the original stuff.

                                      |      BL     |
                                   /                    \
                                 /                       \
   ------------------------/                          \-------------------
   |    OVERRIDE      |                           |   CORE      |
   -------------------------                           --------------------


I have the same exact class stored in both the OVERRIDE and CORE
(where my core stuff in a jar file called core.jar) modules

These identical classes are a package as follows:

package name and files --->

In these packages I have a class called BuildForm

so in OVERRIDE/CORE modules I have

But in my override module I added a method called "getPreferredSize(window)" to class
BuildForm. The "getPreferredSize" method does not exist in my original core module.


Also in the  OVERRIDE package I have another class "" that calls
"getPreferredSize(window)" from the BuildForm class.

This method exist in my OVERRIDE module but not my original CORE module.

Netbeans tells me it cannot find the getPreferredSize. It exist in the same package. But Netbeans is looking at my original CORE module where the class "" does not have this module.

Attached is my pom.xml


 in a classpath way, If I want my class to be used first instead of another class I place "First" in the class path.

I cannot get this to work with my Netbeans Maven Project.

Any recommendations would be appreciated
Summary:. In Java or Maven, how do you tell your Maven Builder to use Class A first instead of Class B? When class A and B are named the same?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


    <name>core overrides</name>


                        <outputDirectory>${}/../mohave BL/packages</outputDirectory>


Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


check here about Maven classpath order:

MNG-1412 / MNG-3111 introduced deterministic ordering of dependencies on the classpath. In the past, natural set ordering was used and this lead to odd results. The ordering is now preserved from your pom, with dependencies added by inheritence added last. In builds that had conflicting or duplicate dependencies, this may introduce a change to the output. In short, if you have weird issues with 2.0.9, take a look at the dependencies to see if you have conflicts somewhere.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
So why can't you put your overriding classes first in the classpath ?
CedarvilleAuthor Commented:
Dear Yan:

I'll check out your link. Yes, I can run my project correctly if I set the classpath. But I want to run in Netbeans. Here's the funny thing;

If I "debug break" in my coreover class I get the following error in netbeans:

Not able to submit breakpoint LineBreakpoint : 192, reason: Breakpoint's source file does not belong into the preferred source root 'D:\netbeans\14sep2011\core\mohave\src\main\java'. See Window/Debugging/Sources.
Invalid LineBreakpoint : 192

Netbeans is just not looking at my module.  Even though Netbeans will let me build this module.

I'll check out the link you sent  and see what I learn.

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

In NetBeans I'd think you certainly cannot have two versions of the source code of the same class.
You can make jar file or say a special folder with only classes of your older files and I hope you can put this folder with old classes
as an external dependency. It should still take the classes generated from your code ar first thing and those which you didn't touch and where you don't have the code it should take form the old stuff - this is my guess, at least.
Generally the way you would accomplish what you want is by extending the base classes to add new functionality, then configuring the application to use your extended class instead of the original.  Generally, building an application that depends on the order JARs are specified in the classpath is a bad idea.  I don't believe (and I might be wrong -- haven't looked at the JLS in a while) that it is mandated for a JDK to include JARs based on command-line ordering and different vendors may implement conflict resolution in multiple ways.

Completely understand that you may have to do things this way because the rest of the code is not configurable, but you're building your application to fail unexpectedly at some point in the future.
CedarvilleAuthor Commented:
For_yan, thank you for the link, it had interesting information.

Gordon, I agree with your statements; I'm trying to do things with module order dependency because my co-workers do this in IntelliJ. I feel like if I knew more I could do this in either Maven or Netbeans as well.

But yes, it is a bad practice.

CedarvilleAuthor Commented:
I got a lot of great comments and pointers. Unfortunately, these were helpful but did not solve my question.

I will do further research. I want to force Maven and Netbeans to honor classpath order; regardless if best practice.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.