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

  • SEARCH
  • Home
  • 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 8304671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:54:41+00:00 2026-06-08T17:54:41+00:00

I have a JAR file that I’m using and I want to modify one

  • 0

I have a JAR file that I’m using and I want to modify one of the files inside it. In a nutshell I have

public class ClassB {
    public void printMethod(){
       ClassA A = new ClassA();
       A.printout();
    }   
}

public class ClassA {
  public void printout(){
    System.out.println("1234");
  }
}

and I want to change ClassA’s printout method to

public class ClassA {
  public void printout(){
    System.out.println("abcd");
  }
}

I know you cannot modify a JAR without unpacking/rebuilding it and for this, let’s say I can’t do that. Is there a way to make modifications to ClassA without actually touching the current ClassA? My approach is to have a new class inherit from ClassA with an overridden method and then have a new class inherit from ClassB that calls the Inherited ClassA

public class InheritedClassA extends ClassA{
  @Override
  public void printout(){
    System.out.println("abcd");
  }
}

public class InheritedClassB extends ClassB{
  @Override
  public void printMethod(){
    InheritedClassA A = new InheritedClassA();
    A.printout();
  }
}

I don’t like this approach though because in my actual JAR, so many classes are using ClassA that its a nightmare trying to correctly do this with all of them, which then all require the same process on them. I know you cannot overload/overwrite a whole class which is basically what I want to do. Is there another way to do this?

EDIT
To make it even harder, I cannot download any new frameworks or software or anything.

  • 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-06-08T17:54:42+00:00Added an answer on June 8, 2026 at 5:54 pm

    One option which may not be feasible would be to create a new version of ClassA, package it up in its own jar file, and put that ahead of the original version in your classpath.

    However, this is a pretty odd scenario – why can you not update the existing jar file? Even if that means a bit of extra work, it’s likely to be much cleaner in the long run than any other approach.

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

Sidebar

Related Questions

I have a jar file that runs this code: public class InputOutput { /**
I have a jar file that I want to put in the shared lib
I have a jar file that I would like to execute using PHP, but
That is when you have any jar file attached to you your class path.
I have a single .jar file that I create by using the runnable .jar
Basically, I have a jar file that i want to unzip to a specific
I have made a .jar file that joins two wave files together.I call it
I have a 3rd party JAR file that is compiled using Java 1.4. Is
I am trying to run a .jar file that I have created using either
I have a codebase that I want to produce several deliverable jar files, each

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.