I am using a shell script to run a .jar file and input parameters. When I cd into the folder containing the relevant files and call the following line, everything works.
cat 'prompt.csv' | sh runScript.sh 'WVFO'
I want to run this from an AppleScript, and when I use the following code, I get an error
do shell script "cat 'path_to_file/prompt.csv' | sh path_to_file/runScript.sh 'WVFO'"
This is the error being raised:
error "Error: Could not find or load main class outputFocalAnalysis.FocalInfoEdge
Caused by: java.lang.ClassNotFoundException: outputFocalAnalysis.FocalInfoEdge" number 1
Finally, here is my sh code:
echo "First arg: $1"
if [ $1 = "WSO" ]; then
echo "WSO found"
java -cp MatrixPath2.0.jar outputFocalAnalysis/FocalInfoVertex
elif [ $1 = "WVFO" ]; then
echo "Must be WVFO"
java -cp MatrixPath2.0.jar outputFocalAnalysis/FocalInfoEdge
else
echo "Argument 1 Invalid"
fi
The folder structure is as follows: Project
is the main folder containing run.scpt
(the AppleScript), prompt.csv
, runScript.sh
, and MatrixPath2.0.jar
.
Edit:
path_to_file
is the complete path to that project folder ie Users/my_name/Documents/Work/Project/prompt.csv
错误Caused by: java.lang.ClassNotFoundException: outputFocalAnalysis.FocalInfoEdge"
表示未在类路径中正确设置jar。请在您的shell脚本中尝试执行以下操作
java -cp path_to_file/MatrixPath2.0.jar outputFocalAnalysis/FocalInfoVertex
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.