我正在用Java编写二十一点游戏。我正在使用不同的公共课程。除了其中一个我得到以下错误的消息之外,所有这些消息都工作正常:
BlackJack.java:161: error: cannot access AudioPlayer
AudioPlayer player = new AudioPlayer();
^
bad source file: ./AudioPlayer.java
file does not contain class AudioPlayer
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
我认为原因是该类中有一个软件包。我不确定自己在做什么错,找不到解决方案。
发生这种情况有两个可能的原因
目录的根目录是否包含在类路径中?启动Java程序时需要指定。 See the documentation on how to do that或this variant for unix。
您的课程公开吗?如果您忘记了公共修饰符,则类将具有程序包可见性,并且无法从其他程序包中访问。
哦,好吧,没人期望西班牙的宗教裁判所……仔细检查您的拼写,包括大写字母。