Results 1 to 8 of 8
  1. #1
    Georgino is offline Member
    Join Date
    Jan 2013
    Location
    London
    Posts
    7
    Rep Power
    0

    Default Error message about class name

    When I try and compile some of my java files I get the error message below (I use mac but I believe it does not really matter):

    error: Class names, 'WhileDemo', are only accepted if annotation processing is explicitly requested

    Sometimes I received this when I tried some codes from text book as well, so I think the problem is not with the code. Can anybody help what could be the problem? http://www.java-forums.org/images/smilies/skype/=(.gif

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error message about class name

    Quote Originally Posted by Georgino View Post
    When I try and compile some of my java files ...
    You left out the most important piece of information: how, exactly did you try to compile?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Georgino is offline Member
    Join Date
    Jan 2013
    Location
    London
    Posts
    7
    Rep Power
    0

    Default Re: Error message about class name

    I wrote the code in TextEdit and compiled it by using iTerm, which is an improved terminal using the javac Filename.java command.

    Quote Originally Posted by DarrylBurke View Post
    You left out the most important piece of information: how, exactly did you try to compile?

    db

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Error message about class name

    OK.
    So what does the file you are trying to compile look like?
    ANd copy/paste the full command you are using and the full error message you receive.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Georgino is offline Member
    Join Date
    Jan 2013
    Location
    London
    Posts
    7
    Rep Power
    0

    Default Re: Error message about class name

    Quote Originally Posted by Tolls View Post
    OK.
    So what does the file you are trying to compile look like?
    ANd copy/paste the full command you are using and the full error message you receive.
    All right here is the full story from a to z:

    The file is very simple and was prepared in TextEdit. It looks like:

    class WhileDemo{
    public static void main(String[] args){

    char ch = 'a';

    while (ch<='z'){
    System.out.println(ch);
    ch++;
    }
    }
    }


    Obviously the file was saved in a separate folder with the same name as the file and with .java extension. I tried to compile it in iTerm, which is an improved Terminal using the following command:

    javac WhileDemo.java

    The error message I got was:

    error: Class names, 'WhileDemo', are only accepted if annotation processing is explicitly requested
    1 error

    Now I experienced the problem with other files as well. Some of them are very simple so I am sure it is not about the coding.
    Last edited by Georgino; 03-08-2013 at 04:06 PM.

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    900
    Rep Power
    2

    Default Re: Error message about class name

    Apparently you get this error when you use the javac command and not include the .java extension. I am not sure why you would get this when running javac WhileDemo.java, but maybe you typed it correctly in this forum and wrongly in your iTerm. Just my 2.
    (Java Compile Problem: Class names are only accepted if annotation processing is explicitly requested - Stack Overflow)

  7. #7
    Georgino is offline Member
    Join Date
    Jan 2013
    Location
    London
    Posts
    7
    Rep Power
    0

    Default Re: Error message about class name

    Quote Originally Posted by SurfMan View Post
    Apparently you get this error when you use the javac command and not include the .java extension. I am not sure why you would get this when running javac WhileDemo.java, but maybe you typed it correctly in this forum and wrongly in your iTerm. Just my 2.
    (Java Compile Problem: Class names are only accepted if annotation processing is explicitly requested - Stack Overflow)
    Unfortunately this is not the case and java keeps doing it with other files as well. Sometimes even files that worked fine before. Very Strange

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error message about class name

    Can you copy the contents of your iTerm showing all relevant commands, and paste it here?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Duplicate Class Error Message
    By bruceaj in forum New To Java
    Replies: 8
    Last Post: 11-05-2011, 11:50 AM
  2. Error message "could not find the main class"
    By srwpchelp in forum New To Java
    Replies: 8
    Last Post: 12-23-2010, 09:15 PM
  3. Replies: 2
    Last Post: 10-02-2010, 02:13 AM
  4. Semantic Error: Message not understood by class
    By JVassie in forum New To Java
    Replies: 5
    Last Post: 04-15-2010, 02:39 PM
  5. Replies: 1
    Last Post: 02-15-2010, 10:32 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
  •