Cannot find main class on Linux - Classpath issue

一曲冷凌霜 提交于 2019-12-04 06:12:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!