我编写了一个Java应用程序。由于复杂的原因,我无法将其作为可执行文件(由于CVS和环境推广实践)导出到Linux。我也无法通过' jar -cvmf'将主类路径添加到MANIFEST.MF。命令,因为它没有安装在应用程序运行的Linux环境中(我无法控制安装的内容)。我找到的唯一其他选项是创建以下shell脚本:
#!/bin/bash
#check that parameters were passed
if [ $# -lt 2 ]; then
echo ""
echo "Not enough arguments provided. You must have at least 2 arguments with ISO SQL time stamps."
echo " After that you can have unlimited number of parameters for tools."
echo ""
exit 1
fi
echo "Recovering events that occurred between $@"
ROOT_DIR=_spool_generator
JAR_DIR=jar
mkdir $ROOT_DIR
mkdir $ROOT_DIR/$JAR_DIR
FULL_DIR=$ROOT_DIR/$JAR_DIR
cp /home/wma/jar/SpoolGenerator.jar ./$FULL_DIR/
echo $@
START=$1
END=$2
java -cp "./$FULL_DIR/SpoolGenerator.jar" com.btv.main.Driver $@ # --> does not work
#java -cp "./$FULL_DIR/SpoolGenerator.jar" com.btv.main.Driver "2001-02-12 18:15:00.0" "2001-02-12 19:15:00.0" --> works
#java -cp "./$FULL_DIR/SpoolGenerator.jar" com.btv.main.Driver "$START" "$END" --> works
echo "Execution is complete..."
exit
这里的关键问题是我有无限数量的应用程序使用的参数。当在Windows中直接部署java应用程序作为可执行文件时,这很有用,如果我指定Shell脚本所采用的位置参数,则可以正常工作,但是如何从Linux脚本中将这些相同的参数传递给java应用程序。由于timstamp的特殊字符,我必须将参数传递给用引号括起来的脚本,当参数传递给jar时,这似乎会导致一些异常的解析。我感谢任何帮助。