Reputation: 1133
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?
Upvotes: 0
Views: 110
Reputation: 3721
java -cp /home/pi/code/java/eclipse/bin Controller
Would be the right way if you have your Controller
class in the default package.
If you try to refer to your class as eclipse.bin.Controller
the Java runtime will look for the Controller
class within the package eclipse.bin
and packages are not directories.
Upvotes: 1