1 Reply Latest reply on Apr 19, 2010 3:13 AM by DrClap

    Reloading class via ClassLoader not working

      Hey guys,
      I'm using ClassLoader via URLClassLoader (from a jar file), and then loading the class i need.
      When the jar file is changed i try to reload the class i need from the new jar but it does not work.
      What am i doing wrong? Is there another way to replace classes in runtime?
      private void createClassLoader()
              File jarFile = new File(EXTERNAL_DOWNLOADERS_JAR);
              if (!jarFile.exists())
                  URL[] urls = {new URL("file://" + EXTERNAL_DOWNLOADERS_JAR)};
                  classLoader = new URLClassLoader(urls);
                  log.log(Level.INFO, "Created class loader " + classLoader);
              catch (MalformedURLException e)
                  log.log(Level.WARNING, "Problem creating class loader: ", e);
      This segment works only at first load but i cannot replace the extDownloader
      Class<?> temp = PersistencyManager.classLoader.loadClass(EXT_DOWNLOADER_PATH + extDownloaderName);
      extDownloader = (ExtDownloader) temp.newInstance();