Loading separate JAR files.

Hello.
I have an application that loads functionality from separate jar files so that the application has a "hot deploy" feature. This means that the application reloads a certain functionallity if a new jar is deployed to that folder. This also means that the jars containing this functionality must be in a separate forlder than the jars for the application framework, or the system would try to load this as a functionallity as well.
In my JNLP file, I load the whole application framework at startup, but none of the functionality jars as these are loaded after the application has logged the user in and so on. I use URLClassLoader to load the funtionality classes but in these classes, I import from the allready loaded framework, and the functionalities I try to load throw an excaption that they do not find the classes in the framework.
Any ideas as to how the externally loaded jars can find classes loaded into the framework? This works perfectly well when I don't use web start, so there must be some class loading issues I am not aware of.
Thank you.
-r

OK, I am making some progress, but now I have a different problem: Some of the framework for loading was written by someone else and I would really like access to the debug information it prints without having to rewrite a lot to print it all to files. Is there any way to get access to everything that is being printed on System.out from web start. Been looking around but I can't find anything on the subject.

Similar Messages

  • How to load a Jar file in the class path?

    How to load a Jar file which contains class files, images, etc.. in the classpath without using URLClassLoader.

    You don't "load" jars. If it's on the classpath, you can obtain individual resources from it using various methods on either Class or ClassLoader. Do you mean "how to add a jar to the classpath at runtime"? Can't be done without using a classloader, typically URLClassLoader or a subclass thereof. Why you want to not use the proven method is beyond me. Presumably because you don't understand classloading. In which case, forget it.

  • Error while loading the jar file using loadjava

    Hi,
    I'm trying to load a jar file in to a database through the loadjava utility. First time when i loaded a jar file it created few public synonyms with /'s. like /5b3d7f97_BeanInfoIndexer.
    Now i want to drop these synonyms before i reload the jar file with loadjava.
    If i use DROP PUBLIC SYNONYM /5b3d7f97_BeanInfoIndexer; it gives the following error...
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    I wonder how to drop these synonyms. I have to drop all these synonyms to freshly load the jar file.
    Thanks
    Shiva

    You can include the synonym names in double quotes in the drop synonym command. But it is not a good idea to drop the synonyms(which have been created by loadjava) using drop synonym command. Instead, you can use dropjava command which will automatically drop all the synonyms created by the loadjava command.

  • Problem while loading a jar file into database

    Hi All,
    We are using Oracle 8.1.5 in Solaris. When I try to load a jar file into the database by using loadjava it gives the following error
    Error while processing jar cryptix32.jar
    Exception java.io.IOException: Load Java is unable to handle compressed entries: cryptix/provider/Cryptix.class
    loadjava: 1 errors
    Can anybody suggest anything to overcome this. Thanks in advance.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by John Emmer ([email protected]):
    I presume you've tried creating the jar w/o compressing it? If not, and even if you didn't create the jar, then first unpack the jar into a directory and re-jar it without using compression.<HR></BLOCKQUOTE>
    Hi John,
    Thanks for your help. I unpacked the jar and rhen re-jared it with -0 (uncompress ) option. The above error is gone. But I am getting another problem. I am getting the following error for all the classes except the property files.
    Error while resolving class cryptix/cryptix/provider/cipher/Rijndael
    ORA-04043: object cryptix/cryptix/provider/cipher/Rijndael does not exist
    But the class is there in the jar. I am able to load single individual classes. Can anybody help me in this matter. Thanks in advance.

  • Error Loading xerces.jar file

    Hi,
    I am getting the following errors while loading the Apache xercesImpl.jar file.
    ORA-29534: referenced object SIRIUS.org/apache/xml/serialize/HTMLSerializer
    could not be resolved
    errors : class org/apache/xml/serialize/XML11Serializer
    ORA-29534: referenced object SIRIUS.org/apache/xml/serialize/XMLSerializer c
    ould not be resolved
    errors : class org/apache/xml/serialize/XMLSerializer
    ORA-29534: referenced object SIRIUS.org/apache/xml/serialize/OutputFormat co
    uld not be resolved
    errors : class org/w3c/dom/html/HTMLDOMImplementation
    ORA-29521: referenced name org/w3c/dom/html/HTMLDocument could not be found
    I am loading the jar file using the following command
    loadjava -user demo/demo@userdemo -resolve xercesImpl.jar
    Any help will be really appricated.
    Thanks in advance
    Mohammad

    Hi,
    Check whether the file is open? close the file and try to pull once again.
    Fields are matching with the data source? check it once. it should be in sync with MData fields.
    and may be the problem with data...I think some Extra permitted chars / lower case is there in flat file. this can be solved by RSKC

  • Weblogic 12c JSF2 and EJB3.1 using CDI injection , in separate jar files

    I am trying to inject a stateless EJB and  managed Bean of JSF2 into a CDI managed controller.
    That means using @inject replace @EJB of EJB and @Named of CDI replace @ManageBean in JSF2 ,  EJB3.1 and JSF2 in separate jar files.
    At result,My  test  gets the following Exception in  weblogic 12c。
    If EJB in separate files and Managed Bean of JSF in WEB-INF/classes not separte file, then no problem.
    weblogic.management.DeploymentException:
         at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ISaleInfoService] with qualifiers [@Default] at injection point [[field] @Inject private com.hylandtec.hystone.showcase.web.SaleInfoBean.saleInfoService]
         at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:258)
         at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
         at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
         at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:361)
         at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:105)
         at com.oracle.injection.integration.CDIAppDeploymentExtension.prepare(CDIAppDeploymentExtension.java:60)
         at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Edited by: user8823518 on 2012-3-12 上午12:49

    This is a Weblogic 12.1.1 bug (a patch is available), explained here:
    http://docs.oracle.com/cd/E24329_01/doc.1211/e26593/issues.htm#BCFGBBBE
    extract:
    If a WAR file has two embedded bean deployment archive JARs (that is, JARs that contain META-INF/beans.xml), an UnsatisfiedDependencyException occurs if a class in one JAR contains an @Inject that is of a type that is defined in the other JAR.
    Workaround
    +Download and install patch 13563205. Enter this value in the Patch Number Search field on the Patches & Updates tab of My Oracle Support.+

  • CLASSPATH issues on DOS/NT and loading of jar files

    Hello all,
    I have the following problem on running WebLogic 5.1 on
    NT. The CLASSPATH is getting truncated after a certain number of
    characters. I have a lot of third party jar files that I use in my
    application. How do I overcome this problem ? I tried increasing my DOS
    environment space by changing the default values in config.sys.
    What are other alternatives ?
    One idea that I have is to use URLClassLoader to load the jar files. I
    am running a RMI based application and I need to load these jar files
    before I load the RMI code. Where would I run this URLClassLoader code
    ? Is there some system startup class that can load jar files ?
    Thanks,
    Aswin.

    Thanks for the reply. I much appreciate it. What about the other idea that I
    had outlined-loading these jar files using a ClassLoader. Is that viable ?
    Aswin.
    Cameron Purdy wrote:
    In Win2k: Control Panel, System, Advanced, Environment Variables
    ComSpec=%SystemRoot%\system32\cmd.exe /e:16384
    You still will not be able to have a command line exceeding a certain size
    (around 1k or so). That is a hardcoded limit somewhere inside the NT kernel
    ("kernel" being a poor term for the piece so named in NT ;-).
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    Tangosol: How Weblogic applications are customized
    "Aswin Dinakar" <[email protected]> wrote in message
    news:[email protected]..
    Hello all,
    I have the following problem on running WebLogic 5.1 on
    NT. The CLASSPATH is getting truncated after a certain number of
    characters. I have a lot of third party jar files that I use in my
    application. How do I overcome this problem ? I tried increasing my DOS
    environment space by changing the default values in config.sys.
    What are other alternatives ?
    One idea that I have is to use URLClassLoader to load the jar files. I
    am running a RMI based application and I need to load these jar files
    before I load the RMI code. Where would I run this URLClassLoader code
    ? Is there some system startup class that can load jar files ?
    Thanks,
    Aswin.

  • Jinit not loading webutil jar files

    Hello,
    Our Application Server has had webutil installed on it for quiet some time now. I am implementing a custom Banner Form that requires webutil functionality. Well the form is all set, but the webutil portion does not function correctly. I have been working with the designers of this application and they recommended I make sure that my archive_jini and archive parameters be set in the file /u01/app/oracle/product/10gASforms/10.1.2/forms/server/formsweb.cfg as follows:
    archive_jini=banicons.jar,bannerui.jar,banspecial.jar,banorep.jar,frmall_jinit.jar,gwucustom.jar,frmwebutil.jar,jacob.jar
    archive=banicons.jar,bannerui.jar,banspecial.jar,banorep.jar,frmall.jar,gwucustom.jar,frmwebutil.jar,jacob.jar
    so I set these up as requested. When I look at my Java Console I only see the following load:
    banicons.jar, bannerui.jar, banspecial.jar, banorep.jar and frmall_jinit.jar
    I do not see gwucustom.jar, frmwebutil or jacob.jar load.
    Is there something I am missing? Do I have to restart the Application Server?
    Thank you much in advance for any guidance anyone can provide!
    -Stan

    I actually corrected this issue myself.
    In the formsweb.cfg file I added these properties under the default section.
    There is a section called jinit_pprd (My Pre-Production test server, I added these values under there and the .jar files are now loading.
    -Stan

  • URLClassLoader + dynamically loading signed jar files

    I have an applet that does not know all of the jar files it will need to load at startup.
    I would like to dynamically load these signed jar files using the URLClassLoader, however it does not recognize these jar files as being signed and I get java.security.AccessControlException: access denied errors.
    Any suggestions?
    Thanks!

    Try this classloader for loading the jars, it should to the trick:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.URLStreamHandlerFactory;
    import java.security.AllPermission;
    import java.security.CodeSource;
    import java.security.PermissionCollection;
    import java.security.Permissions;
    public class AllPermissionsClassLoader extends URLClassLoader {
        public AllPermissionsClassLoader (URL[] urls) {
            super(urls);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent) {
            super(urls, parent);
            System.out.println(parent);
        public AllPermissionsClassLoader (URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
            super(urls, parent, factory);
        protected PermissionCollection getPermissions (CodeSource codesource) {
            Permissions permissions = new Permissions();
            permissions.add(new AllPermission());
            return permissions;
    }

  • Java applet won't load from Jar file

    Hi all,
    I have a problem which I didn't used to have. I have written an applet which used certain classes stored in directories. It used to work just fine. I recently updated the main class from which the applet starts and since then I get error messages:
    Java Plug-in 1.6.0_26
    Using JRE version 1.6.0_26-b03-384-10M3425 Java HotSpot(TM) 64-Bit Server VM
    User home directory = /Users/benoize
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    load: class WiaRekenToolHC.class not found.
    java.lang.ClassNotFoundException: WiaRekenToolHC.class
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:687)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3046)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1498)
         at java.lang.Thread.run(Thread.java:680)
    Exception: java.lang.ClassNotFoundException: WiaRekenToolHC.class
    As you can see it says that it can't find the class WiaRekenToolHC, but it's there in the jar files.
    Here is the link where you can see it:
    www.creativemathsolutions.nl/demo/HC/demo.html
    The jar files are in the directory HC and Generic.
    If you need more info then let me know!
    Regards, Benoit

    <applet
      codebase="http://www.creativemathsolutions.nl/demo/HC"
      code="WiaRekenToolHC.class"
      ARCHIVE="HC/wia_hc_archive_v0_3.jar, Generic/wia_archive_v0_3.jar"
      width=900 height=600>The code-base combined with archive href for the first Jar mean the JRE will look for it at:
    http://www.creativemathsolutions.nl/demo/HC/HC/wia_hc_archive_v0_3.jar
    It is not there. The other Jar is also missing from the stated location.

  • Load a jar file

    Hi every body, in my applet i need to load a lot of class that i put in a .jar file....
    For the classes i used the ClassPreLoader but for the jar file what can i use?
    Thanks in advance...

    Try use package java.util.jar.* like this:
    java.util.jar.JarFile jarFile = ((JarURLConnection) (new URL("...")).openConnection()).getJarFile();
    java.io.InputStream is = jarFile.getInputStream(jarFile.getEntry(name));

  • ImageIcon not loading from Jar file

    Hi,
    I'm developing an application that uses ImageIcons in JButtons.
    The images are stored in the following relative dir:
    images/<filename>.jpg
    They load fine when I run the application from class files in the appropriate directory.
    However when I jar everything, my ImageIcons don't load.
    I know that my jar file is in the classpath, because other items in the jar file load successfully.
    I've tried everything the related threads recommend, but still nothing.
    When I try to launch from the jar file, the ClassLoader.getResource("filepath"); returns null.
    Whereas when I launch the class files, it returns the correct URL for the image.
    What am I missing? Is this jar file security-related? Do I need to sign the jar file with all-permissions?
    Any suggestions would be gratefully appreciated.
    I'm using java 1.4.2_01-b06
    Much thanks,
    -Jeroen

    Here is a little load program that you can use.
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    * <p>Resources extracts all the resources from a jar file into binary large
    * objects. These objects can be used to create images or read as streams.
    * This class is implemented as a singleton model.</p>
    * <p>An attempt is made to find the path to the jar file in
    * if this file is not found no resources are
    * loaded.
    * @author Michael Couck
    * @version 1.00, 16/01/2004
    public final class Resources extends Constants {
          * The only instance of this class
         private static Resources resources;
          * Hashtables for the sizes of the entries in the jar
         private static Hashtable sizes= new Hashtable();
          * Hashtable for each entry in the jar as a blob
         private static Hashtable contents= new Hashtable();
          * Flag to test if the resources were loaded correctly
         private static boolean resourcesLoaded= false;
          * Initilises the <code>static</code> instance of the
          * <code>Resources</code> instance.
         public static void initiliseResources() {
              if (resources == null)
                   resources= new Resources();
          * Instanciates a <code>Resources</code> object.
         private Resources() {
              init();
          * Returns a resource as a <code>byte</code> array, which can then be used
          * as a <code>ByteArrayInputStream</code> to instanciate among other things
          * images and property files.
          * @param name a resource name. This is the path to the recource from the
          *         root of the jar file.
         public static byte[] getResourceAsByteArray(String name) {
              if (resources == null)
                   resources= new Resources();
              return (byte[]) Resources.contents.get(name);
          * Returns true if the resources were correctly loaded
         public static boolean resourcesLoaded() {
              return resourcesLoaded;
          * Reads the jar file and inserts the contents
          * into the Hashtables.
         public void init() {
              try {
                   //Sizes into the table     
                                                                    File jar= new File("[path to]/yourjar.jar");
                   if (jar != null && jar.exists()) {
                        //Found the path to this jar file
                        ZipFile zipFile= new ZipFile(jar);
                        Enumeration enum= zipFile.entries();
                        while (enum.hasMoreElements()) {
                             ZipEntry zipEntry= (ZipEntry) enum.nextElement();
                             sizes.put(
                                  zipEntry.getName(),
                                  new Integer((int) zipEntry.getSize()));
                        zipFile.close();
                        //Contents into the table
                        FileInputStream fis= new FileInputStream(jar);
                        BufferedInputStream bis= new BufferedInputStream(fis);
                        ZipInputStream zis= new ZipInputStream(bis);
                        ZipEntry zipEntry= null;
                        while ((zipEntry= zis.getNextEntry()) != null) {
                             if (zipEntry.isDirectory()) {
                                  continue;
                             int size= (int) zipEntry.getSize();
                             // -1 means unknown size.
                             if (size == -1) {
                                  size=
                                       ((Integer) sizes.get(zipEntry.getName()))
                                            .intValue();
                             byte[] blob= new byte[(int) size];
                             int readBuffer= 0;
                             int buffer= 0;
                             while (((int) size - readBuffer) > 0) {
                                  buffer=
                                       zis.read(blob, readBuffer, (int) size - readBuffer);
                                  if (buffer == -1) {
                                       break;
                                  readBuffer += buffer;
                             contents.put(zipEntry.getName(), blob);
                        resourcesLoaded= true;
              } catch (NullPointerException e) {
                   Constants.logger.severe(e.getMessage());
                   StackTraceElement[] stackTrace= e.getStackTrace();
                   for (int i= 0; i < stackTrace.length; i++) {
                        Constants.logger.severe(stackTrace.toString());
                   resourcesLoaded= false;
              } catch (FileNotFoundException e) {
                   Constants.logger.severe(e.getMessage());
                   StackTraceElement[] stackTrace= e.getStackTrace();
                   for (int i= 0; i < stackTrace.length; i++) {
                        Constants.logger.severe(stackTrace[i].toString());
                   resourcesLoaded= false;
              } catch (IOException e) {
                   Constants.logger.severe(e.getMessage());
                   StackTraceElement[] stackTrace= e.getStackTrace();
                   for (int i= 0; i < stackTrace.length; i++) {
                        Constants.logger.severe(stackTrace[i].toString());
                   resourcesLoaded= false;
    } //End Resources
    You can get the icons with "new ImageIcon(new ByteArrayResources.getResourceAsByteArray(String name));
    See ya
    Michael

  • Class Loader for Jar Files

    I have a set of Jar files which i need to load using Custom Class Loader. Any one who has Javacode for Custom Class Loader for loading Jar files send it. The Jar files are local jar files.

    Here is the class loader I use:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.JarURLConnection;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
    import java.lang.reflect.InvocationTargetException;
    import java.util.jar.Attributes;
    import java.io.IOException;
    * A class loader for loading jar files, both local and remote.
    public class JarClassLoader extends URLClassLoader {
        private URL url;
        private URL[] m_urlList = new URL[10];
         * Creates a new JarClassLoader for the specified url.
         * @param url the url of the jar file
        public JarClassLoader(URL url,ClassLoader cl) {
             super(new URL[] { url },cl);
          this.url = url;
        public JarClassLoader(URL[] urlList,ClassLoader cl) {
             super( urlList,cl);
          this.m_urlList = urlList;
         * Returns the name of the jar file main class, or null if
         * no "Main-Class" manifest attributes was defined.
        public String getMainClassName() throws IOException {
          URL u = new URL("jar", "", url + "!/");
             JarURLConnection uc = (JarURLConnection)u.openConnection();
             Attributes attr = uc.getMainAttributes();
             return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
         * Invokes the application in this jar file given the name of the
         * main class and an array of arguments. The class must define a
         * static method "main" which takes an array of String arguemtns
         * and is of return type "void".
         * @param name the name of the main class
         * @param args the arguments for the application
         * @exception ClassNotFoundException if the specified class could not
         *            be found
         * @exception NoSuchMethodException if the specified class does not
         *            contain a "main" method
         * @exception InvocationTargetException if the application raised an
         *            exception
         public void invokeClass(String name, String[] args) throws ClassNotFoundException,
                NoSuchMethodException,
                InvocationTargetException
             Class c = loadClass(name);
             Method m = c.getMethod("main", new Class[] { args.getClass() });
             m.setAccessible(true);
             int mods = m.getModifiers();
             if (m.getReturnType() != void.class || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) {
             throw new NoSuchMethodException("main");
             try {
               m.invoke(null, new Object[] { args });
             } catch (IllegalAccessException e) {
             // This should not happen, as we have disabled access checks
    }

  • Is it possible to load additional JAR Files?

    Hi,
    I was wondering if it is possible to load JAR files into an existing application. That is, if i have already deployed a JAD file onto a phone and have it running, is it possible to load additional classes into this program to use with the current program?
    This is because depending on user decisions, different classes are needed and having all of them at once will use to much memory.

    No, it's not possible.

  • Dynamic loading of jar files

    Hi,
    I've two servlets, servlet1 and servlet2, running on WebLogic 5.1 with two jar
    files, jar1 and jar2. Both jar files have same directory structure. servlet1 uses
    jar1 while servlet2 uses jar2. How can I make both servlets run at the same time
    under same WebLogic instances using corresponding jar files without changing the
    source code of the java files.
    Thanks
    Krishnan.S

    I don't think so, not if the classes have the same name but different jar names. But if all the classes are uniquely named, then it's no problem.

Maybe you are looking for