0

I've been writing simple programs in Java, but seem to run into problems where the class path is involved.

My compiled class files exists in the directory: /home/pi/code/java/eclipse/bin/

When in this directory I can run "java Controller" and the program will run.

Experimenting with the class path I tried the following:"java -cp /home/pi/code/java/ eclipse.bin.Controller"

But I get the following exception:

"Exception in thread "main" java.lang.NoClassDefFoundError: eclipse/bin/Controller (wrong name: Controller)
"

The weirdest thing is that Java even constructed the final section "eclipse.bin.Controller", e.g. I could tab it when i was typing the command, so I expected this to work.

My end goal is to point the class path at a JDBC driver.

Where am I going wrong?

4

1 回答 1

1
java -cp /home/pi/code/java/eclipse/bin Controller

如果您的Controller课程在默认包中,那将是正确的方法。

如果您尝试引用您的类,eclipse.bin.ControllerJava 运行时将Controller在包中查找该类,eclipse.bin而包不是目录。

于 2013-06-11T20:31:21.357 回答