在Linux上找不到主类 - Classpath问题 [英] Cannot find main class on Linux - Classpath issue

查看:558
本文介绍了在Linux上找不到主类 - Classpath问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux机器上运行几个jar时遇到了一些麻烦。基本上,我收到一个错误,说它无法找到我主罐的主类。该类是非常存在的,所以它必须是类路径问题。
我对linux不太好,所以我正在寻找一些关于我可能会遗漏某些东西的建议。

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.

首先,我正在设置类路径在用户bash_profile中;添加所需的所有jar,由a:delimeter分隔。然后我导出类路径。

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.

然后,在我用来调用主jar的shell(ksh)脚本中,我也使用类路径并在命令中调用它-cp

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

所以它看起来像:

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

输出文件显示所有jre jar正在执行,然后加载jar并抛出一个主类没有找到类的异常。

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

推荐答案

问题在于以下几行:

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

这篇关于在Linux上找不到主类 - Classpath问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆