cana class extend a class which is jar and added to a classpath

Posted on 2009-02-13
Last Modified: 2012-05-06
I have to extend a class which is in different package or which is in server.jar. Is that possible?
I am using eclipse, it does say its not finding parent class.
Question by:cutie_smily
    LVL 86

    Accepted Solution

    It can extend any class that's loadable. To be loadable it must be on your classpath so add the jar to your Build Path (Add jars)
    LVL 26

    Assisted Solution

    as long as you have added server.jar in the Libraries list and the class has the right access( public ), you can

    Author Comment

    Thanks everybody

    Author Comment

    Base class Animal
    sub class cow

    Animal a=new cow();
    a.speak(); //it says Animal does not have speak method.

    Doesn't it get from subclass ?
    LVL 86

    Assisted Solution

    Animal should have it as a method (abstract)
    LVL 92

    Assisted Solution

    Its only possible if the class is not final. If the class is not declared as final then you aref ree to subclass it

    > Base class Animal
    > sub class cow
    > Animal a=new cow();
    > a.speak(); //it says Animal does not have speak method.

    > Doesn't it get from subclass ?

    Need to either use:

    cow a = new cow();

    or cast it:


    or add a speak() method to the Animal class

    LVL 26

    Expert Comment

    >>Doesn't it get from subclass ?

    If the method exist only in the subclass, there is no way the Animal class can point to that method which it not aware of, try object's comment.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Convert BufferedReader to File 1 49
    wordsCount challenge 10 49
    strCount chalenge 3 35
    pairs challenge 5 30
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now