How to Load Classes in run time - Urgent

Hi All,
How to Load a class file from a .jar file in JDK1.1 with out using URLClassLoader. I have tried to extract the .jar file by file input stream and zipEntry classes and defineClass using the bytes i got from the stream , but the class loader fails to take the classes that are already loaded in the system.
The customClassLoader that i created was not able to assign an object to the another reference variable that already in the JVM.Please i want to know how to assign or communicate between the objects of CustomclassLoader and SystemClassLoader?
Please help me in this regard.
Thanks in advance,

Hi,
The above code works in the straight way if the class is available in the classpath.
I need to load a class by using custom class loader that i extends from classloader base class .
I have to read a class file from a .jar file (in server) and load it in run time.Here i am able to read the bytes from the .jar file of the specified class file, but the class that i read extends some other class that is already loaded when i tried to create newInstance of the class i get Exceptions. Here the custom classLoader cannot find the loaded existing class in the JVM.can i get a solution for this situation

Similar Messages

  • How to instantiate classes at run time with constructors having arguments?

    I have to instantiate some classes in the run-time because they are plugins. The name of the plugin (pluginClassName) comes from a configuration file.
    Currently I am doing this to achieve it:-
    UIPlugin plugin = (UIPlugin)Class.forName(pluginClassName).newInstance();However, there is a disadvantage. I can not pass arguments to the constructor of the plugin.
    public class RainyTheme extends UIPlugin {
      public RainyTheme() {
       // bla bla
      public RainyTheme(int x, int y , int width, int height) {
       // set co-ordinates
       // bla bla
      // bla bla bla bla
    }Now if I want to instantiate this plugin at runtime and at the same time I want to pass the 4 arguments as shown in the second constructor, how can I achieve this?

    I have no experience with JME and the limitations of its API, but looking at the API docs ( http://java.sun.com/javame/reference/apis.jsp ) it seems that there are two main versions, CLDC and CDC, of which CLDC is more limited in its API.
    The Class class does not contain the methods getConstructor(Object[]) or getConstructors() in this version ( http://java.sun.com/javame/reference/apis/jsr139/java/lang/Class.html ), so it seems that if you are using CLDC then there is no way to reflectively call a constructor with parameters. You'd have to find another way to do what you want, such as use the noarg constructor then initialise the instance after construction.

  • How to invoke a class at run-time for primitive data types?

    Hi,
    I am trying to invoke classes at run-time.
    I am using Class.forName("className") for that where the "className" is also obtained at run-time .
    The problem I am getting is when the "className" is "int" or "char" etc. the call to Class.forName("int") etc. fails giving ClassNotFound error. It works fine for "className" is "java.lang.String" or "java.lang.Integer" etc.
    How can I correct this?
    thanks in advance-
    kg

    Hi,
    Thanks all for the valuable inputs.
    I have created a hashtable of primitive data types in the form of "int" as key and "Integer.TYPE" as the object in that element of the hashtable.
    Now there is another problem I am facing and that is of 'Casting at run-time'.
    Problem is there when the Database type is 'NUMBER' which returns me a "java.lang.BigDecimal" when I do a ResultSet.getObject("XXX") for that whereas the method in the javabean expects an "int" type.
    This causes "java.lang.IllegalArgumentException: argument type mismatch"
    So I want to cast it at runtime. How can I do it?
    Here is the code I am trying (which generates the above exception)
    public static void setBeanField(Class pCls,Object pObj,String pMethodName ,Object pColumnValue,Class
    pColumnTypeClass){
    try{
    if(pColumnValue!=null){
    Class[] paramTypes = new Class[]{pColumnTypeClass};
    Object[] args = new Object[]{pColumnValue};
    Method meth = pCls.getMethod(pMethodName,paramTypes);
    meth.invoke(pObj,args);
    }catch(Exception e){
    System.out.println("Exception in TestInrospection.setBeanField " + e);
    thanks in advance-
    kg

  • System Error 998 While loading the Labview Run-Time Engine

    Hello.
    I have a DLL made with LV 7.1 I run the dll using a C compiler and works great in WINXP, but cannot run in Win2K. Error is:
    "System error 998 while loading the Labview Run-Time Engin(c:\program
    files\National Instruments\Shared\Labview Run-Time\7.1\\lvrt.dll)
    READVOLTAGE requires a version 7.1 (or compatible) Labview Runtime
    Engine. Please contact the vendor of READVOLTAGE to correct this
    problem"
    READVOLTAGE is my function inside the dll. The runtime is already
    installed. I tried it in another WINXP running machine and works fine.

    This is actually a Microsoft bug with statically loaded DLLs. There are a couple of workarounds for it, and I have included two links below to posts that address this issue:
    Not found error message from LabVIEW runtime when called from VC++ with statically linked MFC
    I get error 998 when calling a LabVIEW buildt DLL from MSVC++
    Kind Regards,
    E. Sulzer
    Applications Engineer
    National Instruments

  • System error 999 while loading the Labview Run-Time Engin

    Bonjour à tous,
    J’ai un PC avec un Runtime LV71.1 qui me retourne l’erreur suivante. Je ne trouve pas d’info sur cette erreur. Une Idée sur la cause ?
    System error 999 while loading the Labview Run-Time Engin(c:\program files\National Instruments\Shared\Labview Run-Time\7.1\\lvrt.dll)
    Luc Desruelle | Voir mon profil | LabVIEW Code & blog
    Co-auteur livre LabVIEW : Programmation et applications
    CLA : Certified LabVIEW Architect / Certifié Architecte LabVIEW
    CLD : Certified LabVIEW Developer / Certifié Développeur LabVIEW
    Résolu !
    Accéder à la solution.

    Bonjour Maxime, merci pour ta réponse qui est très intéressante. Le soft est en LV7.1.1 est fonctionne depuis plusieurs années. Le PC est chez un client, dans un pays très « hostile », je n’ai donc pas accès à ce dernier. Un superviseur local m’a fait le retour qu’après redémarrage du PC ce dernier indiquait un problème, avec photo pour descriptif. Je n’ai pas plus d’info pour le moment. Je viens donc de demander un CHKDSK c: /F
    Luc Desruelle | Voir mon profil | LabVIEW Code & blog
    Co-auteur livre LabVIEW : Programmation et applications
    CLA : Certified LabVIEW Architect / Certifié Architecte LabVIEW
    CLD : Certified LabVIEW Developer / Certifié Développeur LabVIEW

  • How can I test the running time of a method?

    c.What is the running time of your method smallest, as a function of n, the number of elements in the list? Use big-Oh notation.
    I quoated from a java problem..
    Anyone can tell me how I can test the running time? Thanks ! :D

    it depends on what is in the method. For example a for loop executed n times would have a O(n). A double for loop (each loopp run n times) will have O(n^2). Do this: determine how many times each loop in the method is run. This is the first term in your runtime equation. Do this for all other loops in the method and add them all together. Most other statements that are not iterative should have a constant runtime so O(1). For conditional statements, the runtime depends on the most time consuming portion of the statement. Once all these are added together, take the O(equation) which should just leave the biggest term. i.e. O(5n^2+3n+8) = O(n^2). Hope this helps.
    note: this does not apply to recursive methods

  • System Error 31 while loading the LabVIEW Run-Time Engine

    I'm getting the following error message.  I've attached a screen shot of it as well. 
    System Error 31 while loading the LabVIEW Run-Time Engine (<Pathstuff>\\lvrt.dll)
    I'm trying to update an instrument running Windows95.  What is system error 31?  I can't find anything on it using Google or the forum's search function.
    The instrument is a Romulus-IIIA from Quad Group.  I'm pursuing assistance from them as well.
    Solved!
    Go to Solution.
    Attachments:
    Winzeta Error LabVIEW.JPG ‏17 KB

    Howdy Szandstra,
    Check out this KnowledgeBase article describing what you are seeing.  Follow the steps there to correct the problem.  Have a great day, and let me know if that solution doesn't work for you!
    Sincerely,
    Chris G in AE

  • LoadClass    (error loading a class which extends other class  at run-time)

    Hey!
    I'm using the Reflection API
    I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
    CustomClassLoader loader = new CustomClassLoader();
    Class classRef = loader.loadClass("SubClass");
    class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.
    This is what 'findClass(String className)' returns:
    defineClass (className,byteArray,0,byteArray.length);
    'byteArray' is of type byte[] and has the contents of subdir/SubClass.
    the problem:
    The program runs fine if SubClass does not extend any class.
    If however, SubClass extends another class, the program throws a NoClassDefFoundError. How is it conceptually different?
    Help appreciated in Advance..
    Thanks!

    Because i'm a newbie to the Reflection thing, i'm notI don't see reflection anywhere. All I see is class loading.
    sure what role does the superclass play when i'm
    trying to load the derived class and how to get away
    with the errorWell... hint: all the superclass's stuff is not copied into the subclass.
    I am quite sure it fails to load the superclass because of classpath issues.

  • Loading assest at run time: are these on the client?

    The docs say: "If you decide to access an asset at run time,
    you can load it from the local file system of the computer on which
    the SWF file runs", does this mean the client machine?
    If so how do the assets get to the client machine? How do
    they get to the user's network for that matter?
    I am having a serious conceptual block here!
    Tracy

    That quote comes from:
    Building and Deploying Flex 2.0 Applications > Building
    and Deploying Flex Applications > Flex Application Structure
    > Development directory structure > Flex SDK directory
    structure, and the topic is "Sharing assets among applications",
    the sub topic is "Consideration for accessing application assets",
    the third paragraph.
    I absolutely understand embed vs runtime loading, so you will
    understand why this statement is causing cognitive dissonance.
    Tracy

  • How can attach movieclip in run time

    Hi,
    Getting some problem to attach movieclip at run time...............
    I have a shell.swf and at run time i am attaching a template.swf. In template.swf file have mcMenu Movieclip.
    I am unable to access the or attach the movieclip at run time getting this error  (1180: Call to a possibly undefined method mcMenu.)
    that movieclip is not available on the stage.... it is in the library of template.swf file. Need help
    thanks in advance
    flash@dicts

    use the applicationdomain class:
    load(yourswfURL,yourclassString);
    // you don't need to change anything below:
    function load(urlS:String, classS:String) {
        var ldr:Loader = new Loader();
        ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){loadCompleteF(e,classS);});
        ldr.load(new URLRequest(urlS));
    function loadCompleteF(e:Event,classS:String):void {
        var loadedAppDomain:ApplicationDomain = e.target.content.loaderInfo.applicationDomain;
        var C:Class = loadedAppDomain.getDefinition(classS) as Class;
        var instance:* = new C();

  • How to load Classes?

    How to retrive the class name during runtime.....
    suppose if i select java.lang package , i must get all the classes relating to lang package....
    i used reflection API, but using that you can retrive constructor and methods of any class... and i need the classes of perticular package.... how to do it?
    Thank You

    Must it be in run-time? If no classloader tricks are applied, the whole class path contents could be perused to gain a list of the classes available there even berore running your application.

  • Print methods of a class at run-time

    Suppose I have a class. At run-time I get an object of that class. I want to print methods defined in that object using System.out.println(). How can I do that?
    Thanks

    Take a look at Object.getClass(). It returns a Class object. Then look at the methods within the Class class that you can invoke. Some of them return arrays of Method objects, for instance.
    Learn to read the API and experiment with the available methods you already have (such as getClass(), available for every object).
    http://java.sun.com/j2se/1.4.2/docs/api/index.html

  • How can I see a run time error?

    When I run the VI in development mode the VI works just fine. But after I compile and run the VI I get an error that flashes across the screen and then disappears. Arggg! How can I stop the process to see my error?

    Steve,
    There are a few possible solutions to this.
    One, I am writing an article about right now. It involves writing a Loader. This is a simple VI that loads and runs your main program, so that it can remain as a VI. If this is a viable solution for you (your VIs remain as VIs), then it is probably a great solution, as you won't have to worry about why your VI runs differently as an executable than in development.
    The second is a lot more involved. You need to troubleshoot this error. First, you should already have in place some good error handling. If you don't, get it. Once you have it, or if you already do, you need to determine about where the error is coming from, and start putting in some troubleshooting. I always like to create a singl
    e Global Variable (this to me is the ONLY good use for a global) with all sorts of indicators to act as a runtime probe (since you can't probe a built application.) You just write values to various controls as you need them, when you need them, and this allows you to view those values. Since this is designed primarily to view data in reentrant VIs, you will have to create a viewer for your built application. Simply create a VI that loads when you run your app that displays all of the global values.
    Those are the only suggestions I can offer for now. Without knowing the nature of the error, etc, I can't give you any further advice.

  • How can I delete a "Run Time Air" from my mac book pro

    how can I get rid of the "Run Time Air" on my Macbook Pro

    Welcome to the Apple Support Communities
    If you use Snow Leopard, open iTunes, go to iTunes Store in the iTunes sidebar and log out

  • How to design report at run time SSRS

    most of the time we point store procedure or table and then SSRS report designer show us field and we just drag drop those field on to report designer surface. after all we call those report programmatically and pass parameter and report shown on report
    viewer.
    now my company want that customer will customize the report who will see the report. they want to display all the fields in a form and just customer will select each field and place on report designer surface and give some input like filter condition like
    date range or employee id etc and report will be shown. also at run time if customer want they can add text or move existing field etc.
    i do not have any idea how could i do this with SSRS. if this is possible with SSRS then please guide me in such a way as a result i can start the job or if possible give me few relevant url of that kind from where i can get the idea. thanks

    You can also use report builder application to get most of these functionality. For that you'll just create and deploy a report model with required attributes from involved entities.
    Then use can consume the model within report builder and add required fields to report,filter etc
    see below videos for more details
    http://technet.microsoft.com/en-us/sqlserver/dd430326.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for