Contents of page >
- Solve error: Class names are only accepted if annotation processing is explicitly requested
Solve error: Class names are only accepted if annotation processing is explicitly requested
This error occurs when you try to compile your java program and forgot to include .java extension with javac command in CMD.
Let’s take an example >
First let’s write java class >
public class FirstProgram {
public static void main(String[] args) {
System.out.println("This is my first Java Program");
}
}
|
Let’s say above code in file = E:\workspace\FirstProgram.java
Go to CMD and type below commands >
C:\Users\ankitmittal01>e:
E:\>cd E:\workspace
E:\workspace>javac FirstProgram
error: Class names, 'FirstProgram', are only accepted if annotation processing is explicitly requested
1 error
|
Now, let’s solve the problem (error: Class names, 'FirstProgram', are only accepted if annotation processing is explicitly requested) by including .java extension with javac command in CMD.
E:\workspace>javac FirstProgram.java
E:\workspace>java FirstProgram
This is my first Java Program
E:\workspace>
|
As soon as javac FirstProgram.java is called .class file is formed. (.class file contains bytecode)
Directory of .class file = E:\workspace\FirstProgram.class
when java FirstProgram is called it executes the .class file and output of program “This is my first Java Program” is printed in CMD.
Having any doubt? or you 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>
Writing and executing first java program through CMD in windows, Setting up ECLIPSE in java, Directory of .class file
Java tutorial - Advantage, Where is java used in real world, platform independent language
Interface in java - Multiple inheritance, Marker interfaces, When to use interface practically, 12 features
Abstract class in java - When to use abstract class or interface practically, 10 features
Constructor in java - Constructor chaining, access modifiers with constructors, constructor overloading, exception thrown, constructors are not inherited
Labels:
Core Java