我正在尝试运行以下批处理文件来启动 Minecraft 服务器。
运行.bat
@echo off
REM Forge requires a configured set of both JVM and program arguments.
REM Add custom JVM arguments to the user_jvm_args.txt
REM Add custom program arguments {such as nogui} to this file in the next line before the %* or
REM pass them to this script directly
java -Xmx4G @libraries\net\neoforged\neoforge\21.1.37\win_args.txt %*
pause
批处理文件只是调用 java -Xmx4G @libraries 等 精锻 eoforge .1.37\win_args.txt %* 并给我这个错误
Error: Could not find or load main class
@libraries\net\neoforged\neoforge\21.1.37\win_args.txt
这些文件确实存在,如果我在命令提示符下手动运行此命令,我就可以正常启动服务器
那么为什么批处理文件与@文件有问题?
使用java 21运行
我手头没有Windows环境,所以我没有测试下面我的建议。
你尝试过吗:
@echo off
REM Forge requires a configured set of both JVM and program arguments.
REM Add custom JVM arguments to the user_jvm_args.txt
REM Add custom program arguments {such as nogui} to this file in the next line before the %* or
REM pass them to this script directly
"java -Xmx4G @libraries\net\neoforged\neoforge\21.1.37\win_args.txt %*"
pause
或
@echo off
REM Forge requires a configured set of both JVM and program arguments.
REM Add custom JVM arguments to the user_jvm_args.txt
REM Add custom program arguments {such as nogui} to this file in the next line before the %* or
REM pass them to this script directly
java -Xmx4G "@libraries\net\neoforged\neoforge\21.1.37\win_args.txt" %*
pause
在 Windows 批处理文件中,
@
具有特殊含义,而在命令行中则没有该含义。因此,以某种方式掩盖或逃避它应该可以完成这项工作。