Results 1 to 4 of 4
  1. #1
    madnbri is offline Member
    Join Date
    Feb 2014
    Posts
    5
    Rep Power
    0

    Default inheritance failure in same package

    Hi,
    I've tried to write a package and two classes this way:
    <path>/pack/Aclass.java
    Java Code:
    package pack;
    public class Aclass<T> {
      private T t;
    
      public void set(T t) {
        this.t = t;
      }
    
      public T get() {
        return t;
      }
    }
    <path>/pack/Bclass.java
    Java Code:
    package pack;
    public class Bclass<T> extends Aclass<T> {
    }
    In <path>/pack/ directory:
    Java Code:
    javac Aclass.java
    Everything is OK.
    Java Code:
    javac Bclass.java 
    Bclass.java:2: error: cannot find symbol
    public class Bclass<T> extends Aclass<T> {
                                       ^
      symbol: class Aclass
    1 error
    This is not all. Some modification:
    <path>/Bclass.java
    Java Code:
    public class Bclass<T> extends pack.Aclass<T> {
    }
    In <path>/ directory:
    Java Code:
    javac Bclass.java
    Everything is OK.

    What can I do, if I need these in same package?

    Thanks in advance,
    m

  2. #2
    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0

    Default Re: inheritance failure in same package

    You should run javac from /<path>/ not from /<path>/pack.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: inheritance failure in same package

    @OP: do you provide a proper classpath?

    javac -cp <path> *.java

    where <path> is the path to the root of your project, so it contains a subdirectory 'pack' ?
    Last edited by gimbal2; 02-24-2014 at 11:52 AM. Reason: javac command, not java
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    madnbri is offline Member
    Join Date
    Feb 2014
    Posts
    5
    Rep Power
    0

    Default Re: inheritance failure in same package

    Both of these answers helps.
    Thank You

Similar Threads

  1. Replies: 2
    Last Post: 03-26-2013, 07:07 PM
  2. Replies: 3
    Last Post: 03-27-2012, 10:27 AM
  3. Failure of Preferences API under OSX
    By JerryAgin in forum Advanced Java
    Replies: 2
    Last Post: 02-29-2012, 11:20 AM
  4. Replies: 7
    Last Post: 11-09-2009, 08:51 AM
  5. Animation failure...
    By lordbob75 in forum New To Java
    Replies: 10
    Last Post: 05-11-2009, 03:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •