Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling same Method having same packageName From Different JARs
    primarykey
    data
    text
    <p>I have three Jar files.All jar files contain Same class TestServicesImpl And Same Method displayWeLcomeMessage() But having different messages(output) of displayWeLcomeMessage(). <strong>Example :</strong> </p> <pre><code>public void displayWeLcomeMessage() { System.out.println("wecome msg of JAR version first"); } public void displayWeLcomeMessage() { System.out.println("wecome msg of JAR version two"); } public void displayWeLcomeMessage() { System.out.println("wecome msg of JAR version third"); } </code></pre> <p>I have One main application and it contains jars included. My main application calls displayWeLcomeMessage() method.</p> <p>first JAR is added in classpath and second JAR is loaded with custom classloader and invoke method displayWeLcomeMessage().</p> <pre><code> File file = new File("C:/Users/amitk/Desktop/Test_1.0.2.jar"); @SuppressWarnings("deprecation") URL url = file.toURL(); URL[] urls = new URL[]{url}; URLClassLoader loader = new URLClassLoader(urls); Class classS = loader.loadClass("com.amit.servicesImpl.TestServicesImpl"); Object object = classS.newInstance(); Method getmsg = classS.getMethod("displayWeLcomeMessage"); getmsg.invoke(object); </code></pre> <p>but it displays the same message as in method of JAR first. In my third JAR, i have changed the package name. that is <strong>com.amit.servicesImpl.TestServicesImpl</strong> is changed to <strong>com.amit.servicesImpl2.TestServicesImpl</strong> and this time it works properly that is message of method of JAR 3 is displayed here.</p> <p>so let me know the main issue behind this.and solution for this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload