I've been having some trouble setting -classpath properly to get a project to run:
What I thought I was supposed to do:
java -classpath /path/to/classes package.Main
The only thing so far that works:
cd /path/to/classes
java -classpath . package.Main
I've also tried to do -classpath /path/to/classes:.
I need to be able to run that class from different directories so I can't use the solution that did work for me.
I am obviously missing something really stupid here.
EDIT: I am using cygwin
The problem was the way classpath is handled in cygwin:
Since java is a windows program it doesn't recognize the cygwin path I gave.
The fix was:
java -classpath `cygpath -wp /path/to/classes/` package.Main
Hope it helps someone else.
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.