问题
I am having some trouble running a few jar's on a linux box. Basically, I am getting an error saying it cannot find the main class of my main jar. The class is defenetly present so it must be a classpath issue. I am not great with linux, so I am looking for some advice as to where I might be missing something.
First off, I am setting the classpath in the users bash_profile; adding all the jar's required, seperated by a : delimeter. I then export the classpath.
Then, in the shell (ksh) script I use to invoke the main jar, I also st the classpath and call it in the command using -cp
so it looks like:
TEST_ROOTDIR = /Test/app
CLASSPATH=$CLASSPATH:${TEST_ROOTDIR}/lib/myjar.jar
...
export CLASSPATH
CMD_STRING="java -Xms200m -Xmx200m -XX:MaxPermSize=200m -verbose -cp $CLASSPATH"
CMD_STRING="$CMD_STRING <main classpath in jar>"
nohup $CMD_STRING > $OUTPUT_FILE
The output file shows all the jre jar's getting executed, it then loads the jar and throws a class not found exception for the main class.
I am stumped, any help would be greatly appreciated
回答1:
The problem is in the following line:
TEST_ROOTDIR = /Test/app
I'm certain that upon executing the script, it'd have emitted an error message saying:
TEST_ROOTDIR: command not found
which you seem to have ignored. Remove the spaces around =
while setting the environment variable. Say:
TEST_ROOTDIR=/Test/app
来源:https://stackoverflow.com/questions/18714684/cannot-find-main-class-on-linux-classpath-issue