I get this error when I compile my java program:
error: Class names, \'EnumDevices\', are only accepted if annotation
processing is explicitly requested
1
i think this is also because of incorrect compilation..
so for linux (ubuntu).....
javac file.java
java file
chandan@cmaster:~/More$ javac New.java
chandan@cmaster:~/More$ javac New
error: Class names, 'New', are only accepted if annotation processing is explicitly requested
1 error
So if you by mistake after compiling again use javac
for running a program.
How you can reproduce this cryptic error on the Ubuntu terminal:
Put this in a file called Main.java:
public Main{
public static void main(String[] args){
System.out.println("ok");
}
}
Then compile it like this:
user@defiant /home/user $ javac Main
error: Class names, 'Main', are only accepted if
annotation processing is explicitly requested
1 error
It's because you didn't specify .java
at the end of Main
.
Do it like this, and it works:
user@defiant /home/user $ javac Main.java
user@defiant /home/user $
Slap your forehead now and grumble that the error message is so cryptic.
first download jdk from https://www.oracle.com/technetwork/java/javase/downloads/index.html. Then in search write Edit the System environment variables In open window i push bottom called Environment Variables Then in System variables enter image description here Push bottom new In field new variables write "Path" In field new value Write directory in folder bin in jdk like "C:\Program Files\Java\jdk1.8.0_191\bin" but in my OS work only this "C:\Program Files\Java\jdk1.8.0_191\bin\javac.exe" enter image description here press ok 3 times
Start Cmd. I push bottom windows + R. Then write cmd. In cmd write "cd (your directory with code )" looks like C:\Users\user\IdeaProjects\app\src. Then write "javac (name of your main class for your program).java" looks like blabla.java and javac create byte code like (name of your main class).class in your directory. last write in cmd "java (name of your main class)" and my program start work
I was stumped by this too because I was including the .Java extension ... then I noticed the capital J.
This will also cause the "annotation processing" error:
javac myclass.Java
Instead, it should be:
javac myclass.java
Perhaps you may be compiling with file name instead of method name....Check once I too made the same mistake but I corrected it quickly .....#happy Coding