How do I run a java program from a different directory?
问题 I have a java program that I would like to be able to run from anywhere on my machine. I would like to run it from my Cygwin command prompt. I've made scripts to call the java program. I added the location of the java program to the classpath, and the scripts work when I run them from the java program's directory. However, when I try to run from any other directory, I get: java.lang.NoClassDefFoundError: commandprogram/CommandProgram This is my script: #!/bin/sh CWD=`dirname "$0"` java -cp "