我想在没有GUI的情况下运行NetLogo(无头),并且在运行netlogo-headless.sh脚本时遇到问题(即各种“无法识别的选项”)。
我已经扫描了在线内容,并尝试使用该语法;但是,我不是Java的特别熟练者,在寻找解决方案方面遇到了麻烦。
这是netlogo-headless.sh脚本
#!/bin/bash
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ ${JAVA_HOME+1} ]]; then
JAVA="${JAVA_HOME}/bin/java"
else
echo "JAVA_HOME undefined, using java from path. For control over exact java version, set JAVA_HOME"
JAVA="java"
fi;
# -Xmx1024m use up to 4GB RAM (edit to increase)
# -XX:+UseParallelGC The parallel collector maximizes throughput
# -Dfile.encoding=UTF-8 ensure Unicode characters in model files are compatible cross-platform
JVM_OPTS=(-Xmx1024m -XX:+UseParallelGC -Dfile.encoding=UTF-8)
OPTS_INDEX=2
ARGS=()
INDEX=0
for arg in "$@"; do
if [[ "$arg" == "--3D" ]]; then
JVM_OPTS[OPTS_INDEX++]="-Dorg.nlogo.is3d=true"
elif [[ "$arg" == -D* ]]; then
JVM_OPTS[OPTS_INDEX++]="$arg"
else
ARGS[INDEX++]="$arg"
fi
done
RAW_CLASSPATH="Java/args4j-2.0.12.jar:Java/asm-all-5.0.4.jar:Java/asm-all-5.0.4.jar:Java/asm-all-5.0.4.jar:Java/autolink-0.6.0.jar:Java/autolink-0.6.0.jar:Java/behaviorsearch.jar:Java/commons-codec-1.10.jar:Java/commons-codec-1.10.jar:Java/commons-logging-1.1.1.jar:Java/commons-logging-1.1.1.jar:Java/config-1.3.1.jar:Java/config-1.3.1.jar:Java/flexmark-0.20.0.jar:Java/flexmark-0.20.0.jar:Java/flexmark-ext-autolink-0.20.0.jar:Java/flexmark-ext-autolink-0.20.0.jar:Java/flexmark-ext-escaped-character-0.20.0.jar:Java/flexmark-ext-escaped-character-0.20.0.jar:Java/flexmark-ext-typographic-0.20.0.jar:Java/flexmark-ext-typographic-0.20.0.jar:Java/flexmark-formatter-0.20.0.jar:Java/flexmark-formatter-0.20.0.jar:Java/flexmark-util-0.20.0.jar:Java/flexmark-util-0.20.0.jar:Java/gluegen-rt-2.3.2.jar:Java/gluegen-rt-2.3.2.jar:Java/httpclient-4.2.jar:Java/httpclient-4.2.jar:Java/httpcore-4.2.jar:Java/httpcore-4.2.jar:Java/httpmime-4.2.jar:Java/httpmime-4.2.jar:Java/java-objc-bridge-1.0.0.jar:Java/jcommon-1.0.16.jar:Java/jfreechart-1.0.13.jar:Java/jhotdraw-6.0b1.jar:Java/jhotdraw-6.0b1.jar:Java/jmf-2.1.1e.jar:Java/jmf-2.1.1e.jar:Java/jna-4.2.2.jar:Java/jogl-all-2.3.2.jar:Java/jogl-all-2.3.2.jar:Java/json-simple-1.1.1.jar:Java/json-simple-1.1.1.jar:Java/log4j-1.2.16.jar:Java/log4j-1.2.16.jar:Java/macro-compat_2.12-1.1.1.jar:Java/macro-compat_2.12-1.1.1.jar:Java/macro-compat_2.12-1.1.1.jar:Java/netlogo-6.0.4.jar:Java/netlogo-6.0.4.jar:Java/netlogo-mac-app.jar:Java/parboiled_2.12-2.1.3.jar:Java/parboiled_2.12-2.1.3.jar:Java/parboiled_2.12-2.1.3.jar:Java/picocontainer-2.13.6.jar:Java/picocontainer-2.13.6.jar:Java/picocontainer-2.13.6.jar:Java/rsyntaxtextarea-2.6.0.jar:Java/rsyntaxtextarea-2.6.0.jar:Java/scala-library-2.12.0.jar:Java/scala-library.jar:Java/scala-library.jar:Java/scala-parser-combinators_2.12-1.0.4.jar:Java/scala-parser-combinators_2.12-1.0.5.jar:Java/scala-parser-combinators_2.12-1.0.5.jar:Java/shapeless_2.12-2.3.2.jar:Java/shapeless_2.12-2.3.2.jar:Java/shapeless_2.12-2.3.2.jar"
CLASSPATH=''
for jar in `echo $RAW_CLASSPATH | sed 's/:/ /g'`; do
CLASSPATH="$CLASSPATH:$BASE_DIR/$jar"
done
CLASSPATH=`echo $CLASSPATH | sed 's/://'`
# -classpath .... specify jars
# org.nlogo.headless.Main specify we want headless, not GUI
# "${ARGS[0]}" pass along any additional arguments
$JAVA "${JVM_OPTS[@]}" -Dnetlogo.extensions.dir="${BASE_DIR}/extensions" -classpath "$CLASSPATH" org.nlogo.headless.Main "${ARGS[@]}"
这是终端的输出
~/filepath \
java_home: unrecognized option `-mx1024m'
java_home: unrecognized option `-:+UseParallelGC'
java_home: unrecognized option `-Dfile.encoding=UTF-8'
java_home: unrecognized option `-Dnetlogo.extensions.dir=/Users/filepath/NetLogo6.0.4/extensions'
java_home: unrecognized option `-classpath'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>JVMArch</key>
<string>x86_64</string>
<key>JVMBlacklisted</key>
<false/>
<key>JVMBundleID</key>
<string>com.oracle.java.11.0.1.jdk</string>
<key>JVMEnabled</key>
<true/>
<key>JVMHomePath</key>
<string>/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home</string>
<key>JVMIsBuiltIn</key>
<false/>
<key>JVMName</key>
<string>Java SE 11.0.1</string>
<key>JVMPlatformVersion</key>
<string>11.0</string>
<key>JVMVendor</key>
<string>Oracle Corporation</string>
<key>JVMVersion</key>
<string>11.0.1</string>
</dict>
</array>
</plist>
我应该能够传递此命令并指定要用作实验和模型文件的文件;但是,在达到这一点之前,我一直收到此错误。