• Register
0 votes
932 views

Problem:

I face this error when I compile my java program:

error: Class names, 'MyDevices', are only accepted if annotation

processing is explicitly requested

1 error

Here is the javac command:

javac -cp /home/myname/Desktop/JCuda-All-0.3.2-bin-linux-x86_64 MyDevices

How can I compile my program?

7 5 2
3,870 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I had also faced the similar issue in the recent past. I did lot of research on it and found the solution on it. This is the very common problem with the people getting started.

Your error "Class names are only accepted if annotation processing is explicitly requested" can be caused by one or more of the below:

  1. Not using the .java extension for the java file when compiling.
  1. Improper capitalization of your .java extension (i.e. .Java) when compiling.
  1. Any other typo in your .java extension when compiling.
  1. When compiling and running at the same time and forgetting to use '&&' to concatenate the two commands (example. javac Hangman.java java Hangman). It took me like 30 minutes to figure this out, which I noticed by running my compilation and the running the program separately, which of course worked perfectly fine for me.

This may not be the complete list of the causes to this error, but these are the causes that I am aware of so far.

9 7 4
38,600 points
0 votes

Solution:

You at least require to include the .java extension to the file name in this line:

javac -cp /home/manish.yadav/Desktop/JCuda-All-0.3.2-bin-linux-x86_64 EnumDevices

From the official faq:

Class names, 'HelloWorldApp', are just received in case annotation processing is bluntly requested

In case you accepts this error, you forgot to add the .java suffix at the time compiling the program. Keep in mind, the command is javac HelloWorldApp.java not javac HelloWorldApp.

Further, in your second javac-example, (in which you really added .java) you require to add the all required .jar-files needed for compilation.

This will also happened the "annotation processing" error:

javac myclass.Java 

Instead, it must be:

javac myclass.java 

Employing javac ClassName.java to compile the program, then employ java ClassName to execute the compiled code. You can't mix javac with the ClassName just (without the java extension).

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

Hence in case you by mistake after compiling again employ javac for running a program.

This error happens at the time you attempt to compile your java program and forgot to add .java extension with javac command in CMD.

example >

write java class >

public class FirstProgram {
    public static void main(String[] args) {
           System.out.println("This is my first Java Program");
    }
}

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

Presently, let’s solve the problem (error: Class names, 'FirstProgram', are just received in case annotation processing is explicitly requested) by adding .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 comprise bytecode)

Hence you would run:

javac PezDispenser.java

 

10 6 4
31,120 points

Related questions

1 vote
1 answer 149 views
149 views
Problem : I am very new to Java Programming. I am often facing below error if I try to compile the Java program: error: Class names, 'MyDevices', are only accepted if annotation processing is explicitly requested 1 error Please find below my Java code. I am trying ... command: javac -cp /home/stewart/Desktop/JCuda-All-0.3.2-bin-linux-x86_64 MyDevices How should I compile my above Java program?
asked Apr 28, 2020 stewart 4k points
0 votes
1 answer 4 views
4 views
Problem: How to fix this > Only accepted if annotation processing is explicitly requested
asked May 5 sumaiya simi 43.9k points
0 votes
1 answer 34 views
34 views
I get this error when I compile my java program. How do I compile this program?
asked Dec 14, 2020 TeamScript 13.5k points
0 votes
1 answer 2 views
2 views
Problem: I got this error messaje while trying to copile a simple Java program. I know there is this question already here on Stack but the solution(that i forgot to include the .java suffixwhen compiling the program) still doesn't work for me. This is the program: import java.io ... ("Hello, my name is %s\n", firstName); console.printf("%s this is learning how to write Java\n", firstName); } }
asked Apr 30 muktaa 34.6k points
0 votes
1 answer 11 views
11 views
Problem: are only accepted if annotation processing is explicitly requested 1 error
asked Feb 24 Hira 2.2k points
0 votes
1 answer 30 views
30 views
Problem: I get this error when I compile my java program: error: Class names, 'EnumDevices', are only accepted if annotation processing is explicitly requested 1 error
asked Feb 7 ahmedadel9090 3.1k points
0 votes
1 answer 6 views
6 views
Problem: java class names are only accepted if annotation
asked Feb 24 Hira 2.2k points
0 votes
1 answer 6 views
6 views
Problem: I know running javac file1.java produces file1.class if file1.java is the only source file, then I can just say java file1 to run it. However, if I have 2 source files, file1.java and file2.java, then how do I build the program?
asked May 3 anika11 32.2k points
0 votes
1 answer 66 views
0 votes
1 answer 12 views
12 views
Problem: What are my options for dealing with this issue? pip is not recognized as an internal or external command operable program or batch file
asked Apr 1 rakib1 51.5k points