简体   繁体   中英

Could not find or load main class?

So I compiled a java file (all in OS X terminal) and now when I try to run it, it's giving me the "Could not find or load main class" error. Here's the command:

java -cp "./mysql-connector-java-bin.jar" JavaFile

The mysql connector jar file is in the same directory as the JavaFile but I think it's just not able to find the JavaFile?

Can anyone help me with this?

Thanks!

Add current directory too to the class path. Something like -

java -cp "./mysql-connector-java-bin.jar:." JavaFile

This will include all files in the current directory including your mysql connector jar and your runnable class file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM