javac error: Class names are only accepted if annotation processing is explicitly requested
You at least need to add 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 only accepted if annotation processing is explicitly requested
If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp.
Also, in your second javac-example, (in which you actually included .java
) you need to include the all required .jar-files needed for compilation.
Class names, 'Introductions', are only accepted if annotation processing is explicitly requested
There are two different commands to compile Java programs and run Java programs. You're receiving an error that means that the command to compile the program (javac
) has received arguments that don't include the .java suffix, as mentioned in other questions about this error.
It sounds, however, like you are compiling correctly, using javac Introductions.java
. Your problem is actually in the second step, running the program. Running javac Introductions
tells Java you want to compile again, and so it correctly points out that you forgot the extension.
But you're not wanting to compile a second time; you want to run it! That uses java
instead of javac
.
To compile: javac Introductions.java
To run: java Introductions
See also How do I run a Java program from the command line on Windows? (though this isn't really Windows-specific).
Cannot run compiled java class, error: Class names are only accepted if annotation processing is explicitly requested
You're calling javac
, the compiler, to run your program. You run the program via java
, not javac
. Your second command should be:
java -cp DAT.jar;Exceptions.jar TestQueueString
Note no "c" on "java", and I've added the classpath since you added it when compiling.
Re your edit: The problem there is exactly what it says it is: It can't find the class TestQueueString
. I can think of two possible reasons for this:
The current directory is not in your classpath; try:
java -cp DAT.jar;Exceptions.jar;. TestQueueString
(Note the
;.
at the end of the classpath.)Your
TestQueueString.java
file has apackage
declaration. If so, you need to telljava
the full name of the class (e.g.,foo.TestQueueString
not justTestQueueString
if it were in packagefoo
), and the file has to be in the right place relative to the current working directory (again assuming packagefoo
, the class file would have to be in afoo
subdirectory).
Given the error message you've quoted, and assuming you're using an up-to-date version of Java, I'd guess #1, since #2 would say something like
Exception in thread "main" java.lang.NoClassDefFoundError: TestQueueString (wrong name: foo/TestQueueString)
...(note the "wrong name" bit) if the package were foo
.
Error in code - Class names are only accepted if annotation
You seem to have translated:
do repeat stmt
until A[ j ] ≤ x;
into
do {
stmt;
} while (A[j] >= x);
This is not correct. The comparison which is the opposite of ≤ would be >, not ≥. Therefore, your comparison when translating from "until" to "while" would use > such as while (A[j] > x);
.
The other errors in your possible homework are similar and I encourage you to think each translation through carefully on your own.
Related Topics
Dynamic Generic Typing in Java
Java: Global Exception Handler
Difference Between "This" And"Super" Keywords in Java
How to Find the Index of an Element in an Int Array
Often Big Numbers Become Negative
Printf %F with Only 2 Numbers After the Decimal Point
What Do Curly Braces in Java Mean by Themselves
Why Is Method Overloading and Overriding Needed in Java
Is There a Sophisticated File System Monitor for Java Which Is Freeware or Open Source
How to Use Session in Jsp Pages to Get Information
Java List Sorting: How to Keep a List Permantly Sorted Automatically Like Treemap
Parsing String to Local Date Doesn't Use Desired Century
Create Simple Pojo Classes (Bytecode) at Runtime (Dynamically)