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 "$CWD/classes;$CWD/lib/AJarFile.jar" commandprogram/CommandProgram
Changing the java line to the following:
java -cp "$CWD/classes;$CWD/classes/commandprogram;$CWD/lib/AJarFile.jar" CommandProgram
produces the same results.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…