javac 오류 : 주석 처리가 명시 적으로 요청 된 경우에만 클래스 이름이 허용됩니다.
Java 프로그램을 컴파일 할 때이 오류가 발생합니다.
error: Class names, 'EnumDevices', are only accepted if annotation
processing is explicitly requested
1 error
다음은 자바 코드입니다 (우분투에서 실행 중입니다).
import jcuda.CUDA;
import jcuda.driver.CUdevprop;
import jcuda.driver.types.CUdevice;
public class EnumDevices {
public static void main(String args[]) {
CUDA cuda = new CUDA(true);
int count = cuda.getDeviceCount();
System.out.println("Total number of devices: " + count);
for (int i = 0; i < count; i++) {
CUdevice dev = cuda.getDevice(i);
String name = cuda.getDeviceName(dev);
System.out.println("Name: " + name);
int version[] = cuda.getDeviceComputeCapability(dev);
System.out.println("Version: " +
String.format("%d.%d", version[0], version[1]));
CUdevprop prop = cuda.getDeviceProperties(dev);
System.out.println("Clock rate: " + prop.clockRate + " MHz");
System.out.println("Threads per block: " + prop.maxThreadsPerBlock);
}
}
}
다음은 javac 명령입니다.
javac -cp /home/manish.yadav/Desktop/JCuda-All-0.3.2-bin-linux-x86_64 EnumDevices
이 프로그램을 어떻게 컴파일합니까?
최소한 .java
다음 줄의 파일 이름에 확장자 를 추가해야합니다 .
javac -cp /home/manish.yadav/Desktop/JCuda-All-0.3.2-bin-linux-x86_64 EnumDevices
로부터 공식 자주 묻는 질문 :
클래스 이름 'HelloWorldApp'은 주석 처리가 명시 적으로 요청 된 경우에만 허용됩니다.
이 오류가 발생하면 프로그램을 컴파일 할 때 .java 접미사를 포함하는 것을 잊은 것입니다. 명령은 javac HelloWorldApp이 아니라 javac HelloWorldApp.java입니다.
또한 두 번째 javac-example (실제로 포함 .java
)에는 컴파일에 필요한 모든 필수 .jar- 파일 을 포함해야합니다 .
I was stumped by this too because I was including the .Java extension ... then I noticed the capital J.
This will also cause the "annotaion processing" error:
javac myclass.Java
Instead, it should be:
javac myclass.java
Using javac ClassName.java to compile the program, then use java ClassName to execute the compiled code. You can't mix javac with the ClassName only (without the java extension).
I learned that you also can get this error by storing the source file in a folder named Java
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.
i think this is also because of incorrect compilation..
so for linux (ubuntu).....
javac file.java
java file
The error "Class names are only accepted if annotation processing is explicitly requested" can be caused by one or more of the following:
- Not using the .java extension for your java file when compiling.
- Improper capitalization of the .java extension (i.e. .Java) when compiling.
- Any other typo in the .java extension when compiling.
- When compiling and running at the same time, forgetting to use '&&' to concatenate the two commands (i.e. javac Hangman.java java Hangman). It took me like 30 minutes to figure this out, which I noticed by running the compilation and the running the program separately, which of course worked perfectly fine.
This may not be the complete list of causes to this error, but these are the causes that I am aware of so far.
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.
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
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
To avoid this error, you should use javac command with .java extension.
Javac DescendingOrder.java <- this work perfectly.
If ur file is saved as example: hello.java and
class Example.Do this in cmd
javac hello.java
java Example
That works.
you review path javac.exe and java.exe
D:\Test>"C:\jdk1.7.0_80\bin\javac.exe" TestMain.java D:\Test>"C:\jdk1.7.0_80\bin\java.exe" TestMain.java
'IT story' 카테고리의 다른 글
SQLite-다른 데이터베이스의 테이블을 어떻게 조인합니까? (0) | 2020.08.30 |
---|---|
jQuery의 mouseout ()과 mouseleave ()의 차이점은 무엇입니까? (0) | 2020.08.30 |
Google 개발자 키는 어디에서 얻을 수 있습니까? (0) | 2020.08.30 |
AngularJS 시드 : JavaScript를 별도의 파일 (app.js, controllers.js, directives.js, filters.js, services.js)에 넣기 (0) | 2020.08.30 |
AngularJS : ngInclude 대 지시문 (0) | 2020.08.30 |