Results 1 to 7 of 7
  1. #1
    g123456 is offline Member
    Join Date
    Dec 2009
    Posts
    34
    Rep Power
    0

    Default Wierd problem with abstract and extends

    For some weird reason i can no longer compile things that i could compile.. in fact it was so strange that i went back to the java sun official tutorials and tried to compile an example


    Java Code:
    abstract class GraphicObject {
        int x, y;
       
        void moveTo(int newX, int newY) {
            
        }
        abstract void draw();
        abstract void resize();
    }

    and

    Java Code:
    class Circle extends GraphicObject {
        void draw() {
           
        }
        void resize() {
            
        }
    }
    class Rectangle extends GraphicObject {
        void draw() {
            
        }
        void resize() {
            
        }
    }


    this which is an example from a java tutorial in java official website
    gives the following error :


    after typing /javac GraphicObject.java

    it compiles correctly ( note thats the abstract class )

    after typing /javac Circle.java it says it can't find the GraphicObject class which i am trying to extend..


    I don't think i have really changed my JRE or my JDK at all for 1 year now and i am almost sure that the last time i tried to compile such a thing it worked... and whats even more weird is that netbeans finds it as an error too while this tutorial is quite popular in the internet..

    also let me note that the java files are all in the same folders...

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    I had no difficulty compiling the classes you listed.
    Here is my set-up and the procedure I followed.
    (I did nothing exceptional.)

    I'm using Windows XP, and Java 1.6.
    I have a cmd console on the desktop, which I
    click on to access java. (no Eclipse, netbeans,
    or anything fancey.)

    I broke up your code into three seperate files
    and compiled them in this order:

    javac GraphicObject.java
    javac Circle.java
    javac Rectangle.java

    I did everything the way I would do any other
    code and I had no problems.

  3. #3
    g123456 is offline Member
    Join Date
    Dec 2009
    Posts
    34
    Rep Power
    0

    Default

    i did the same and i have problems.. whats going on? javac problem?

  4. #4
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    There is very little more that I can add,
    other than the

    GraphicObject.class
    Circle.class
    Rectangle.class

    files appeared on the desktop after compiling.

  5. #5
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    My guess (and it is just a guess) is that you have a CLASSPATH, and "." representing the current directory is not in it. The default CLASSPATH is just "." which should not give the results you are seeing. Again, it's just a guess, but it may get you started in a helpful direction.

    -Gary-

  6. #6
    g123456 is offline Member
    Join Date
    Dec 2009
    Posts
    34
    Rep Power
    0

    Default

    yeah could be i will just try to re-make the system variables for the java runtime enviroment


    hmm i have changed the classpath recently to set up apache's ant for easier compilations maybe thats the problem
    Last edited by g123456; 05-14-2010 at 07:19 PM.

  7. #7
    g123456 is offline Member
    Join Date
    Dec 2009
    Posts
    34
    Rep Power
    0

    Default

    Wow i just fixed it by fixing a bit the classpath.. i can't believe i wasted 5 hours of my coding time to figure such a thing.... that reminded me of something "Expect the unexpected"

Similar Threads

  1. wierd NetBeans problem.
    By edi.gotieb in forum Forum Lobby
    Replies: 2
    Last Post: 10-09-2010, 02:31 PM
  2. Replies: 2
    Last Post: 10-23-2009, 03:48 AM
  3. Replies: 3
    Last Post: 09-16-2009, 10:27 PM
  4. Replies: 2
    Last Post: 11-21-2008, 01:20 AM
  5. wierd problem
    By f_the_cook in forum Advanced Java
    Replies: 4
    Last Post: 10-09-2008, 06:13 PM

Posting Permissions

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