javac 错误:仅当显式请求注释处理时才接受类名 [英] javac error: Class names are only accepted if annotation processing is explicitly requested

查看:25
本文介绍了javac 错误:仅当显式请求注释处理时才接受类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译我的java程序时出现这个错误:

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

这是 java 代码(我在 Ubuntu 上运行这个).

Here is the java code (I'm running this on Ubuntu).

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 命令:

Here is the javac command:

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

我如何编译这个程序?

推荐答案

你至少需要在这一行的文件名中添加.java扩展名:

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

来自官方常见问题:

类名称HelloWorldApp"仅在明确请求注释处理时才被接受

如果您收到此错误,则是您在编译程序时忘记包含 .java 后缀.请记住,命令是 javac HelloWorldApp.java 而不是 javac HelloWorldApp.

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.

此外,在您的第二个 javac 示例中(您实际上在其中包含了 .java),您需要包含编译所需的 all 所需的 .jar 文件.

Also, in your second javac-example, (in which you actually included .java) you need to include the all required .jar-files needed for compilation.

这篇关于javac 错误:仅当显式请求注释处理时才接受类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆