Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:41:54+00:00 2026-05-23T07:41:54+00:00

Suppose I have have a java project myProject and am using an external library

  • 0

Suppose I have have a java project myProject and am using an external library jar (someJar.jar), which has a class com.somepackage.Class1.class.

Now I find an updated version of Class1.java which fixes a bug in the original jar.

I include the new Class1.java in my source code under package com.somepackage

When I build the project (e.g., using Netbeans), there is a dist\myProject.jar which contains the classcom.somepackage.Class1.class and a dist\lib\someJar.jar which also contains a class with the same name.

When I run the file (e.g, using java -jar dist\myProject.jar), the new version of Class1.class is used (as I want).

  1. How does Java decide which class file to run in case of such duplicates? Is there any way I can specify precedence ?

  2. Is there any ‘right’ way to avoid such clashes?

  3. In Proguard, when I try to compress my code, I get a duplicate class error. How do I eliminate this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:41:55+00:00Added an answer on May 23, 2026 at 7:41 am
    1. Java decides which one to use based on the order of the classpath. List yours first and you’ll be fine.

    2. The “right” way would be to fix the orignal source, but sometimes that’s not always an option.

    3. I haven’t used ProGuard, but I have re-jarred libaries before that had duplicate classes. The solution in my case was to tell Ant to ignore duplicate classes. I would assume ProGuard would have that support too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose, I have a lot of classes, which are constructed using Java reflection (for
I have made a project in NetBeans IDE using a custom library (a .JAR
Suppose that I have a Java class with a static method, like so: class
Say suppose I have the following Java code. public class Example { public static
In Java, suppose I have 3 classes, C extends from B which extends from
I have a Java project that has both server and client packages. In addition
I'm working on a Java project where I have created a class that looks
so suppose I have a java package.... it's got the main class with the
I have a java project which includes settings, bin, src, .classpath, .project. I am
Suppose I have a Maven 2 Java project on my local machine. I build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.