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.

Similar Messages

  • Abstract class extends other class?

    What happens when a abstract class extends other class?
    How can we use the abstract class late in other class?
    Why do we need an abstract class that extends other class?
    for example:-
    public abstract class ABC extends EFG {
    public class EFG{
    private String name="";
    private int rollno="";
    private void setName(int name)
    this.name=name;
    private String getName()
    return this.name;
    }

    shafiur wrote:
    What happens when a abstract class extends other class?Nothing special. You have defined an abstract class.
    How can we use the abstract class late in other class?Define "Late". What "other class"?
    Why do we need an abstract class that extends other class?Because it can be useful to define one.

  • ?Is it possible to create a javafx class without extending Application class ? If yes, how

    Is it possible to create a javafx class without extending Application class ? If yes, how ?

      There is no  such thing as a javafx  class.  It is a regular  java class.  The Aapplication class is  the entry
    point  for JavaFX application.  You have to extend the Application class to create Javafx  application .

  • Can I use the inner class of one containing class by the other class

    Can I use the inner class of one containing class by the other class in the same package as the containing class
    eg I have a class BST which has inner class Enumerator. Can I use the inner class from the other class in the same pacckage as BST?

    Inner classes do not share the namespace of the package of the containing class. Also they are never visible to other classes in the same package.Believe what you want, then, if you're going to make up your own rules about how Java works. For people interested in how Java actually works, here is an example that shows why that assertion is false:
    package com.yawmark.jdc;
    public class Outer {
         public class Inner {
    }And...
    package com.yawmark.demo;
    import com.yawmark.jdc.*;
    public class Demo {
         public static void main(String[] args) {
              assert new Outer().new Inner() != null;
    }~

  • TS3694 my i pad is showing connect to i tunes picture when i connect to i tunes it tells me i need to restore, but when i do it keeps coming up with error code!! which is a different one each time can anyone offer some advise to solve this frustrating pro

    my i pad is showing connect to i tunes picture when i connect to i tunes it tells me i need to restore to factory settings, but when i do it keeps coming up with error code!!   which is a different one each time can anyone offer some advise to solve this frustrating problem.

    iPad: Basic troubleshooting
    http://support.apple.com/kb/TS3274
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/TS3694
     Cheers, Tom

  • Any possibility for loading and changing XFL/... data at run time of Flash app?

    Hi everybody,
    I have a quick and general question for the following case:
    I want to produce some transitions and effects for a kinetic typography project in After Effects and then import these parts into Flash Professional via XFL and Bridge.
    So my actual problem is this one: my Flash application should be able to load these made transitions and effects dynamically at run-time and not from a pre-configured timeline made upfront. Because there should be dynamic text fields in these XFL data from After Effects I also need to be loaded at run-time for the kinetic typography thing.
    So is there any possible way to do / load / change the dynamic text fields in these XFL data or the order of all transitions and effects in Flash Professional at run-time or anything else?
    I know this is a special question, but I hope there would be an answer...
    Thanks for your help in advance
    Regards,
    Kevin

    Something along this model is what I had in mind:
    public class MainPanel extends JPanel
        private DrawPanel drawPanel = new DrawPanel();
        private JComboBox comboLeft = new JComboBox();
        private JComboBox comboRight = new JComboBox();
        public MainPanel()
            // add drawpanel and comboboxes to main panel
            // add item listener to comboboxes
        private class ComboListener implements ItemListener
            @Override
            public void itemStateChanged(ItemEvent arg0)
                if (...) // both comboboxes changed
                    // get values from comboboxes
                    drawPanel.setValues(left, right); // call drawpanel's method
    public class DrawPanel extends JPanel
        private int left = 0;
        private int right = 0;
        public DrawPanel()
            //setPreferredSize(....); // set panel size
        @Override
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            //... draw the line depending on the left and right value
        public void setValues(int left, int right)
            this.left = left;
            this.right = right;
            repaint();
    }

  • Invoke a panel object in a class which extends JFrame

    I have a class LoginUI which extends JFrame and another class NewUserUI which extends JPanel. The LoginUI contains a button which when clicked should display the NewUserUI panel in a separate window. How should I invoke the NewUserUI object in the LoginUI class?

    One possibility would be the use of a JOptionPane containing the JPanel.
    Cheers
    DB

  • Creating array of objects of class which extends Thread

    getting NullPointerException
    can i not create thread array this way?
    class sample extends Thread
    { int i,id;
      public sample(int c)
       { id=c;
      public void run()
      { for(i=0;i<6;i++)
         System.out.println("Thread "+id+" "+i);
    public class thread extends Frame implements ActionListener
    {  Button b1;
       sample s[];
       thread()
       { for(int i=0;i<2;i++)
              s=new sample(i);
         setLayout(new FlowLayout());
         b1=new Button("OK");
         add(b1);
         b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
         {   b1.setEnabled(false);
              for(int i=0;i<2;i++)
              { s[i]=new sample(i);
              s[i].start();
         public static void main(String args[])
         { thread t1=new thread(); 
         t1.setVisible(true);
         t1.setSize(150,150);

    You need:
    sample [] s = new sample[2];However
    1) You should get into the habit that class names start with capital letters, variable and field names with lower case.
    2) It's not a good idea to extend Thread, make a class which implements the Runnable interface and hook a standard Thread object to that.

  • Retrieve method from class which extends JFrame

    hi, i need some help with my program.
    I have two class which both extends JFrame. The first class called security class and second class is available class.
    In the SECURITY class, i create a button to operate the AVAILABLE class and it generate a result in method Count(). I want to view the result in Frame SECURITY by calling method count() but i could manage to do it. Could somebody help me how to manage this problem?
    Thanks.

    may be you could create a instance of the class you wanted to access method from or pass the instance from one class to another.
    like this:
    public class A extends JFrame
    public B newB= new B();
    public A(){}
    public void someMethod()
    newB.someOtherMethod();
    public class B extends JFrame
    public B(){}
    public void someOtherMethod()
    i hope it is what you are looking for

  • Adding a JPanel from one class to another Class (which extends JFrame)

    Hi everyone,
    So hopefully I go about this right, and I can figure out what I'm doing wrong here. As an exercise, I'm trying to write a Tic-Tac-Toe (TTT) game. However, in the end it will be adaptable for different variations of TTT, so it's broken up some. I have a TTTGame.java, and TTTSquareFrame.java, and some others that aren't relavent.
    So, TTTGame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              addPanel = startSimple();
              if(!addPanel.isValid())
                   System.out.println("Something's wrong");
              contents.add(addPanel);
              setSize(300, 300);
              setVisible(true);
         public JPanel startSimple()
              mainSquare = new TTTSquareFrame(sides);
              mainSquarePanel = mainSquare.createPanel(sides);
              return mainSquarePanel;
    }and TTTSquareFrame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.Misc;
    public class TTTSquareFrame
         private JPanel squarePanel;
         private JButton [] squares;
         private int square, index;
         public TTTSquareFrame()
              System.out.println("Use a constructor that passes an integer specifying the size of the square please.");
              System.exit(0);
         public TTTSquareFrame(int size)
         public JPanel createPanel(int size)
              square = (int)Math.pow(size, 2);
              squarePanel = new JPanel();
              squarePanel.setLayout(new GridLayout(3,3));
              squares = new JButton[square];
              System.out.println(MIN_SIZE.toString());
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setRolloverEnabled(false);
                   squares[i].addActionListener(bh);
                   //squares[i].setMinimumSize(MIN_SIZE);
                   squares[i].setVisible(true);
                   squarePanel.add(squares[i]);
              squarePanel.setSize(100, 100);
              squarePanel.setVisible(true);
              return squarePanel;
    }I've successfully added panels to JFrame within the same class, and this is the first time I'm modularizing the code this way. The issue is that the frame comes up blank, and I get the message "Something's wrong" and it says the addPanel is invalid. Originally, the panel creation was in the constructor for TTTSquareFrame, and I just added the mainSquare (from TTTGame class) to the content pane, when that didn't work, I tried going about it this way. Not exactly sure why I wouldn't be able to add the panel from another class, any help is greatly appreciated.
    I did try and cut out code that wasn't needed, if it's still too much let me know and I can try and whittle it down more. Thanks.

    Yea, sorry 'bout that, I just cut out the parts of the files that weren't relevant but forgot to compile it just to make sure I hadn't left any remnants of what I had removed. For whatever it's worth, I have no idea what changed, but something did and it is working now. Thanks for your help, maybe next time I'll post an actual question that doesn't somehow magically solve itself.
    EDIT: Actually, sorry, I've got the panel working now, but it's tiny. I've set the minimum size, and I've set the size of the panel, so...why won't it respond to that? It almost looks like it's being compressed into the top of the panel, but I'm not sure why.
    I've compressed the code into:
    TTTGame.java:
    import java.awt.*;
    import javax.swing.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              mainSquare = new TTTSquareFrame(sides.intValue());
              contents.add(mainSquare);
              setSize(400, 400);
              setVisible(true);
    }TTTSquareFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class TTTSquareFrame extends JPanel
         private JButton [] squares;
         private int square, index;
         private final Dimension testSize = new Dimension(50, 50);
         public TTTSquareFrame(int size)
              super();
              square = (int)Math.pow(size, 2);
              super.setLayout(new GridLayout(size, size));
              squares = new JButton[square];
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setMinimumSize(testSize);
                   squares[i].setVisible(true);
                   super.add(squares[i]);
              setSize(200, 200);
              setVisible(true);
    I've made sure the buttons are smaller than the size of the panel, and the panel is smaller than the frame, so...
    Message was edited by:
    macman104

  • Create a new class which extends DataGrid

    Can someone give me a simple example on how to create a new
    class that extends DataGrid. Still having a little trouble
    understanding classes.
    Thanks for any help.
    Jeremy

    import mx.controls.DataGrid
    public class MyGrid extends DataGrid {
    It is pretty much as you would extend a class in Java

  • How to access a method of a class which just known class name as String

    Hi,
    Now I have several class and I want to access the method of these class. But what I have is a String which contain the complete name of the class.
    For example, I have two class name class1and class2, there are method getValue in each class. Now I have a String containing one class name of these two class. I want to access the method and get the return value.
    How could I do?
    With Class.forName().newInstance I can get a Object. but it doesn't help to access and execute the method I want .
    Could anybody help me?
    Thanks

    Or, if Class1 and Class2 have a common parent class or interface (and they should if you're handling them the same way in the same codepath)...Class c = Class.forName("ClassName");
    Object o = c.newInstance(); // assumes there's a public no-arg constructor
    ParentClassOrInterface pcoi = (ParentClassOrInterface)o;
    Something result = pcoi.someMethod(); Or, if you're on 5.0, I think generics let you do it this way: Class<ParentClassOrInterface> c = Class.forName("ClassName");
    // or maybe
    Class<C extends ParentClassOrInterface> c = Class.forName("ClassName");
    ParentClassOrInterface pcoi = c.newInstance();
    Something result = pcoi.someMethod();

  • How can a class listen to other class's aoutput

    I have 2 classes which are both unrelated. but i want one class to listen to the output emitted by the other class. eg, class A continuosly prints messages and these messages, i want to be there in class B ...
    Any suggestions?

    I have 2 classes which are both unrelated. but i want
    one class to listen to the output emitted by the
    other class. eg, class A continuosly prints messages
    and these messages, i want to be there in class B
    Any suggestions?Classes do not listen to other classes but objects created from the classes can listen to other objects.
    eg.
    class A {
        public void sendMessage(B b) {
           b.setMessage(String aMessageFormA);
        public static void main(String[] args) {
            A a = new A();
            B b = new B();
            a.sendMessage(b);
            b.printMessageFromA();
    }

  • How to get class name of a object in run time, from its accessible context.

    Hi,
    I need to get the class name of a java object in run-time, given the AccessibleContext of that object.
    I gone through the AccessibleContext api documentation. but there is not way to get the class name for a java object using its AccessibleContext object.
    Do any one have any idea how to get the class name of an java object, given its accessible object Accessible.
    Thanks
    Timberlake

    816311 wrote:
    Please try to provide a solution for my requirement and avoid evaluating a requirement.
    I am a curious guyit's great to be curious. however, in this situation, the requirement makes no sense in the given context. so, in an effort to be helpful, the people on this forum are asking you the reason behind the requirement. the reason we do this is because we have experience answering questions on this forum and, more often than not, requirements which don't make sense are the result of misunderstandings or confusion on the part of the person making the requirement. if we can figure out why you want to do what you want to do, we may be able to point you in a direction which makes more sense.

  • Loading XSL file in XSL Transforam action at run time

    Hello everyone ,
    I want to use XSL Transforamtion action in weblogic integration and name of
    XSL file should pick at run time from a variable.
    I am using :"com.bea.wlxt.repository" package APIs for connecting to repository &
    get the XSL file from it. Check the following code
    RepositoryURL repURL = new RepositoryURL();
    URL myUrl = repURL.create
    ("wlxt://xslt/4112req-mli0018req-xsl");
    InputStream in = myUrl.openStream();
    This code gives me error that "java.io.IOException:Entity 4112req-mli0018req-xsl"
    not found in repository.
    Where as the file is actually present in the root of the repository. I am not sure
    why I am getting this error. Has somebody done something similar ? I am doing something
    wrong ?
    Any help in this regard is appreciated.
    Thanks in advance
    -Kiran R.

    Hi !
    I'm struggelig with the same problem, did you find any solution ?
    Thanks in advance
    Jon Rustand
    "Kiran Rane" <[email protected]> wrote:
    >
    Hello everyone ,
    I want to use XSL Transforamtion action in weblogic integration
    and name of
    XSL file should pick at run time from a variable.
    I am using :"com.bea.wlxt.repository" package APIs for connecting to
    repository &
    get the XSL file from it. Check the following code
    RepositoryURL repURL = new RepositoryURL();
    URL myUrl = repURL.create
    ("wlxt://xslt/4112req-mli0018req-xsl");
    InputStream in = myUrl.openStream();
    This code gives me error that "java.io.IOException:Entity 4112req-mli0018req-xsl"
    not found in repository.
    Where as the file is actually present in the root of the repository.
    I am not sure
    why I am getting this error. Has somebody done something similar ? I
    am doing something
    wrong ?
    Any help in this regard is appreciated.
    Thanks in advance
    -Kiran R.

Maybe you are looking for

  • JSF layout driving me crazy!

    I've been working hard on a jsf powered project manager and am running into some problems with IE compatability. I got everything aligned and positioned the way (more or less) I wanted it, but when I tested it against IE all hell broke loose (specifi

  • Error "getDRMAdditionalHeader failed." of PHDS in AMS5.0.5

    Hi, I am trying to update AMS version from 5.0.3 to 5.0.5. But I could not get manifest file(f4m) of PHDS VoD for "Internal Server Error." Please Help me to PHDS config for AMS 5.0.5. Host OS :  CentOS 5.8 and 6.3 64bit. Reproducibility: install # ta

  • Afctl automatic firewall

    I am having a fair number of ssh brute force attacks on my server. The afctl firewall takes care of these attacks initially by adding rules with ipfw. The rule numbers start at 1700, and the it looks like multiple rules are added for each offending I

  • Registring dll

    I am getting below error when I running this code regsvr32 AppHostNavigators.dll The module "AppHostNavigators.dll" failed to load. Make sure the binary is stored at the specified path or debug it to chec k for problems with the binary or dependent.D

  • Extracting method names from JNI probes

    Hello. I would like to use the Call* probes from the hotspot_jni provider. These probes provide as argument a "method id". My question is how I can extract, for instance, the method name from this ID. I saw that JNI provides a method "GetMethodName"