我'尝试编写一些代码来学习如何在java中使用协议缓冲区,这里是文件夹结构:
- JAVA
- com
- game
- enumeration
- GameEnumProtos.java
- info
- GameInfoProtos.java
- JAVA_TEST.java
- protobuf-java-2.5.0.jar
JAVA_TEST.java:
import com.game.info.GameInfoProtos;
public class JAVA_TEST {
public static void main(String[] args) {
}
}
以及我如何编译(没有错误或警告):
javac JAVA_TEST.java ./com/game/info/GameInfoProtos.java ./com/game/enumeration/GameEnumProtos.java -classpath protobuf-java-2.5.0.jar
当我尝试运行代码时出现错误:
java JAVA_TEST
Exception in thread "main" java.lang.NoClassDefFoundError: JAVA_TEST (wrong name: com/JAVA_TEST)
感谢任何帮助,谢谢:)
@Albert
我尝试了你建议的(macos)运行
java -cp protobuf-java-2.5.0.jar:. com.game.info.GameInfoProtos .JAVA_TEST
在" java"文件夹,但得到错误:
Error: Could not find or load main class .JAVA_TEST