Results 1 to 13 of 13
  1. #1
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default Java in unfamiliar realms !!

    I am an amateur programmer and learning languages 'for the sake of learning' and not necessarily for becoming a fire-brand programmer. I had started with C++ and have quite a lot of proficiency with it. Along the way, I found that Java has a familiar code and I have done quite a lot of codes on it as well. I have practised on command prompt(on win98 only), Eclipse, JCreator and drJava, the latter three on both windows. Everything was going well till something like the following arrived.
    Java Code:
    public class GradeBookTest
       {
          
          public static void main( String args[] )
          {
             
            GradeBook myGradeBook = new GradeBook();
    
             myGradeBook.displayMessage();
         } 
    
      }
    And everything has gone for a toss. Nothing seems to work and it is so frustrating.
    I have installed jdk1.5.0_18( on win98/winXP). On winXP I had continued all my practice without even setting path(Of course, on win98 I had to set path for working on command prompt)
    The present situation is that even after setting the path on winXP ,as follows, nothing appears to work.

    ''""go to MY COMPUTERS
    -->properties
    -->advanced
    -->environment variables

    now u have user variables and system variables
    below user variables u have 3 options

    new edit delete

    click on new

    a box with varaiable name and variable value gets opened
    enter variable name as 'class path'
    variable value as

    (drivein which java is stored):\program files\java\jdk(version)\lib;

    egs: C:\program files\Java\jdk1.6.0\lib;

    enter variable name as 'path'
    variable value as

    (drive in which java is stored):\program files\java\jdk(version)\bin;

    egs: C:\program files\Java\jdk1.6.0\bin;''""

    What I am curious to know is whether there is a quantum jump in Java due to which it has entered unfamiliar realms requiring substantial change in working environment ??

  2. #2
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    What errors are you getting? Do you have the GradeBook class in your project?

  3. #3
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    I am on win98 and on the following code in drJava (which shows compiler jdk5.0_18)
    Java Code:
    public class GradeBookTest
       {
          
          public static void main( String args[] )
          {
             
            GradeBook myGradeBook = new GradeBook();//Error Here
    
           
            myGradeBook.displayMessage();
         } 
    
      }
    And I am getting the following error
    """
    Error:cannot find symbol
    symbol: class GradeBook
    location: class GradeBookTest
    """

  4. #4
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    yep as I thought, GradeBook is a User written class. Write a GradeBook class and that error will go away.

    That code looks familiar, is it out of a book?

  5. #5
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by logicbug View Post
    Write a GradeBook class and that error will go away.

    That code looks familiar, is it out of a book?
    How do I write ??
    Yes, it is out of a book.

  6. #6
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    hmm, not to familiar with OO then?

    in a seperate file in your project
    Java Code:
    public class GradeBook {
          public GradeBook() { //This is your constructor }
    
          // your code calles this method from within GradeBook so you have to write it too
         public void  displayMessage() { System.out.println "GradeBooks display message"; }
    }
    hope that helps

  7. #7
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    Java Code:
    public class GradeBook {
          public GradeBook() { //This is your constructor} 
    
          // your code calles this method from within GradeBook so you have to write it too
         public void  displayMessage()  //Error: Illegal start of expression
         { 
           System.out.println ("GradeBook display message");
           }
        }        //Error: Expected ;
    }
    I am very sorry, the code appears to be from chapters I have not attempted yet. However if you wish you may provide help.

  8. #8
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    Thats alright, If you have any other questions don't be afraid to ask!

  9. #9
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    Many many thanks !! This code relates to which chapter ??

  10. #10
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    no idea, your the one with the book. Which book are you using anyway?

  11. #11
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    In the book I got recently, Java How To Program( I have been practising from other books) this code ,surprisingly, appears very early in chap 3 -- Classes and Objects. Is the student required to know so much so early ??

  12. #12
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Yes... in Java, Classes are the basis of all programs. In fact, it is possible to write a fully functional program using nothing but Classes, however, this can become difficult and make code difficult for a more advanced programmer to understand, as Classes, Interfaces, and Enums are used for different reasons. However, with a bit of work, it is possible to create a class that will imitate an Interface or an Enum, though you cannot use multiple Classes that act as an Interface within a class, as Java does not support multiple inheritance. However, you should definitely focus on learning about Classes, and as for Objects, well, an instance of a Class is, in effect, an Object. If I were you, I would do some very thorough reading of that chapter.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  13. #13
    mgm2010 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    Many many thanks, everyone !! It has been an enlightening discussion.

Similar Threads

  1. Mighty Realms Hearts gets Reviewed!
    By Xyle in forum Java Software
    Replies: 0
    Last Post: 04-11-2009, 05:20 AM
  2. Unfamiliar Syntax "int x = i1 << 24 | i2 ..."
    By KentDMc in forum New To Java
    Replies: 5
    Last Post: 04-11-2009, 04:21 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
  •