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

查看:113
本文介绍了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 )您需要包含编译所需的所有所需的.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天全站免登陆