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

You are here : Home / Core Java Tutorials /


In this java tutorial we will solve error: Class names, 'className', are only accepted if annotation processing is explicitly requested


Contents of page >
  • 1) Why error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested occurs>
  • 2) First create below java program in E:\MyJavaProgram.java>
  • 3) Let’s try to create class file of above program using CMD, Go to CMD, and try to compile java file by typing below command to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
    • Way 1 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
    • Way 2 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
    • Way 3 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
    • Way 4 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
  • 4) For solving this error: Class names, 'className', are only accepted if annotation processing is explicitly requested


1) Why error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested occurs>
  • Extension .java was missing during compilation of java file.
  • .Java was used, J was capital, it should have been .java during compilation of java file.
  • jav was used, it should have been .java
  • class name used was incorrect during compilation of java file.

Now let’s discuss all above ways in detail.


2) First create below java program in E:\MyJavaProgram.java>
public class MyJavaProgram{
public static void main(String[] args) {
     System.out.println("This is MyClass");
}
}



3) Let’s try to create class file of above program using CMD, Go to CMD, and try to compile java file by typing  below command to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >

Way 1 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
E:\>javac MyJavaProgram
error: Class names, 'MyJavaProgram', are only accepted if annotation processing is explicitly requested
1 error

Reason of error :
Extension .java was missing.

Way 2 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
E:\>javac MyJavaProgram.Java
error: Class names, 'MyJavaProgram.Java', are only accepted if annotation processing is explicitly requested
1 error


Reason of error :
.Java was used, J was capital, it should have been .java

Way 3 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
E:\>javac MyJavaProgram.jav
error: Class names, 'MyJavaProgram.jav', are only accepted if annotation processing is explicitly requested
1 error

Reason of error :
.jav was used, it should have been .java


Way 4 to produce error: Class names, ‘className’, are only accepted if annotation processing is explicitly requested >
E:\>javac MyJavaProg
error: Class names, 'MyJavaProg', are only accepted if annotation processing is explicitly requested
1 error


Reason of error :
class name used was incorrect (it should have been MyJavaProgram)
And
.java was missing






4) For solving this error: Class names, 'className', are only accepted if annotation processing is explicitly requested

E:\>javac MyJavaProgram.java
E:\>

And problem is resolved, class file is created in E:\MyJavaProgram.class


Summary >
In this core java tutorial we read why error: Class names, 'className', are only accepted if annotation processing is explicitly requested occurs, how to reproduce it. And solved it.


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



RELATED LINKS>

Solved - Failed to load the JNI shared Library - JDK - eclipse

Resolve Error: Could not find or load main class

error: Class names are only accepted if annotation processing is explicitly requested in java: solution

Find out Java version (32 or 64 bit) installed in your system using java

Find eclipse version in your system



eEdit
Must read for you :