Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 20 of 20

Thread: HELP Error Parsing File

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HELP Error Parsing File

    Hi there I have a few error messages coming up with my code, if someone could point me in the right direction

    regards

    gerry
    package supermarketproject;
     
    public class LinkedQueue<T> implements QueueADT<T>
    {
       private int count;
       private LinearNode<T> front, rear;
     
       /**
        * Creates an empty queue.
        */
       public LinkedQueue()
       {
          count = 0;
          front = rear = null;
       }
     
        public boolean isEmpty( ) {
            return front == null;
        }
     /**
        * Adds the specified element to the rear of this queue.
        *
        * @param element  the element to be added to the rear of this queue
        */
       public void enqueue (T element)
       {
          LinearNode<T> node = new LinearNode<T>(element);
     
          if (isEmpty())
             front = node;
          else
             rear.setNext (node);
     
          rear = node;
          count++;
       }
     
       public T dequeue() throws EmptyCollectionException
       {
          if (isEmpty())
             throw new EmptyCollectionException ("queue");
     
          T result = front.getElement();
          front = front.getNext();
          count--;
     
          if (isEmpty())
             rear = null;
     
          return result;
       }
     
       /**
        * Sets up this exception with an appropriate message.
        */
     public ElementNotFoundException (String collection)
       {
          super ("The target element is not in this " + collection);
       }
    }
    /**
     * EmptyCollectionException represents the situation in which a collection
     * is empty.
     */
     
    public class EmptyCollectionException extends RuntimeException
    {
       /**
        * Sets up this exception with an appropriate message.
        */
       public EmptyCollectionException (String collection)
       {
          super ("The " + collection + " is empty.");
       }
    }
    }
    Last edited by gerry123; July 20th, 2011 at 05:14 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    I have a few error messages
    Sorry, I don't see your error messages???

    Please edit your code and wrap it in code tags. See:BB Code List - Java Programming Forums

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    Quote Originally Posted by Norm View Post
    Sorry, I don't see your error messages???

    Please edit your code and wrap it in code tags. See:BB Code List - Java Programming Forums
    As you can see i have put the code in question in bold

    regards

    gerry

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    Can you explain what the problem is with that code?

    You said:
    I have a few error messages coming up with my code
    Please copy and paste the full text of those error messages here.

  5. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    i have underlined the error messages in question

    regards

    gerry

    public ElementNotFoundException (String collection) invalid method declaration; return type required{
    super ("The target element is not in this " + collection); constructor Object in java.lang.Object cannot be applied to given types; required: no arguments, found: java.lang.String, reason: actual and formal argument lists different in length. call to super must be first statement in constructor}
    }
    /**
    * EmptyCollectionException represents the situation in which a collection
    * is empty.
    */

    public class EmptyCollectionException extends RuntimeException classEmptyCollectionException is public, should be declared in a file named EmptyCollectionException.java
    {
    /**
    * Sets up this exception with an appropriate message.
    */
    public EmptyCollectionException (String collection)
    {
    super ("The " + collection + " is empty.");
    }
    }
    } class, interface, or enum expected

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    That is a very confusing post. Why are the error messages mixed in with the source code?

    public ElementNotFoundException (String collection) invalid method declaration; return type required
    The code looks like a constructor (no return type) but the compiler thinks it is a method definition.
    Check the placement of the code.
    Which is it? A method or a constructor? Where is the class statement for it?

    public class EmptyCollectionException extends RuntimeException classEmptyCollectionException is public, should be declared in a file named EmptyCollectionException.java
    That message is self explanatory. Move the class to its own named file.

  7. #7
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    the error messages are not mixed in with the source code, i typed the underlined text out manually to show u what the errors were

    regards

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    It be better to just post the error messages without any editing.

    Or to leave a blank line between the source and the error message.

  9. #9
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: HELP Error Parsing File

    I must say this thread is rather confusing.

    gerry123, the code or highlight tags are used to keep the code neat and add syntax highlighting which both make it easier to read.

    You also need to post all your code and give us something we can attempt to compile.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  10. #10
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    package supermarketproject;
     
    public class LinkedQueue<T> implements QueueADT<T>
    {
       private int count;
       private LinearNode<T> front, rear;
     
       /**
        * Creates an empty queue.
        */
       public LinkedQueue()
       {
          count = 0;
          front = rear = null;
       }
     
        public boolean isEmpty( ) {
            return front == null;
        }
     /**
        * Adds the specified element to the rear of this queue.
        *
        * @param element  the element to be added to the rear of this queue
        */
       public void enqueue (T element)
       {
          LinearNode<T> node = new LinearNode<T>(element);
     
          if (isEmpty())
             front = node;
          else
             rear.setNext (node);
     
          rear = node;
          count++;
       }
     
       public T dequeue() throws EmptyCollectionException
       {
          if (isEmpty())
             throw new EmptyCollectionException ("queue");
     
          T result = front.getElement();
          front = front.getNext();
          count--;
     
          if (isEmpty())
             rear = null;
     
          return result;
       }
     
       /**
        * Sets up this exception with an appropriate message.
        */
     
    public ElementNotFoundException (String collection)
       {
          super ("The target element is not in this " + collection);
       }
    }
    below is where the errors are within the code, what exactly am i missing in this code?
    /**
     * EmptyCollectionException represents the situation in which a collection
     * is empty.
     */
     
    public class EmptyCollectionException extends RuntimeException
    {
       /**
        * Sets up this exception with an appropriate message.
        */
       public EmptyCollectionException (String collection)
       {
          super ("The " + collection + " is empty.");
       }
    }
    }
    Last edited by JavaPF; July 21st, 2011 at 02:53 PM. Reason: added highlight tags.

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    Please copy and paste here the full text of the error messages.
    Not too many of us are compilers. We need the errors from the compiler to be able to tell you what the compiler sees is wrong with your code.


    Did you read post#6?

    Please edit your code and wrap it in code tags. Use Go Advanced, select your code and press the # icon above the input box.

  12. #12
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    Quote Originally Posted by Norm View Post
    Please copy and paste here the full text of the error messages.
    Not too many of us are compilers. We need the errors from the compiler to be able to tell you what the compiler sees is wrong with your code.


    Did you read post#6?

    Please edit your code and wrap it in code tags. Use Go Advanced, select your code and press the # icon above the input box.
    All it says is as follows "error parsing file"

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    All it says is
    What is the "it"?
    Can you get to a javac compiler?
    Use that to get error messages with some meaning.

  14. #14
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    im using netbeans they dont clearly define error messages, what is a javac compliler?

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    The javac compiler is the one installed with the JDK from Oracle.

  16. #16
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: HELP Error Parsing File

    What IDE do you use?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  17. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    I don't use a proper IDE. I have an enhanced editor - syntax hilighting and multiple projects each with commandlines

  18. #18
    Junior Member
    Join Date
    Jul 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP Error Parsing File

    Quote Originally Posted by Norm View Post
    The javac compiler is the one installed with the JDK from Oracle.
    after running the file i got the following message;

    run:
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at supermarketproject.SuperMarketSimulator.main(Super MarketSimulator.java:23)
    Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class QueueADT
    at supermarketproject.LinkedQueue.<clinit>(LinkedQueu e.java:7)
    ... 1 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,824
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: HELP Error Parsing File

    Where is QueueADT defined?

    after running the file i got the following message;
    IDEs are magic. This source won't compile. There is no way to execute it.
    How can you "run" it?

  20. #20
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    471
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: HELP Error Parsing File

    I can see where one error comes from - at the bottom of your LinkedQueue class, there is a method defined that doesn't have a return value specified, so it looks like a constructor, but it isn't a constructor. See under 'Sets up this exception with an appropriate message.'

    ETA - I notice Norm pointed this out very early on in the thread...
    Last edited by dlorde; July 24th, 2011 at 08:01 PM.

Similar Threads

  1. Code for parsing .c file in java
    By Kakashi in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: March 6th, 2013, 12:51 AM
  2. [SOLVED] Parsing a text file in java
    By tccool in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 16th, 2010, 05:23 AM
  3. ERROR WHILE PROCESSING JSF FILE
    By Pankaj in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: July 10th, 2010, 01:42 AM
  4. Input file parsing to insert into DB
    By IDForums in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 30th, 2009, 03:29 AM
  5. Error while deploying .ear file
    By urslalitha in forum Exceptions
    Replies: 1
    Last Post: August 18th, 2009, 03:56 AM