繁体   English   中英

无法打开使用一个批处理打开的Jar文件,使用另一个批处理文件打开该文件

[英]Cant open Jar file which is open using a batch which is opened using another batch file

我正在尝试打开一个批处理文件,该文件由另一个应启动我的jar文件的批处理文件打开。

这是批处理文件的行,我用它来打开ServerStart.bat以启动我的jar文件。 (位于我的桌面上的test.bat。)

set runmc1="C:\\Game Host\\mc_ftb_monster-1.6.4\\ServerStart.bat"

这是ServerStart.bat

java -Xms2048m -Xmx2048m -XX:PermSize=128m -jar FTBServer-1.6.4-965.jar nogui

然后我得到这个: http : //i.imgur.com/MhV4xC7.jpg

我在Google上度过了数小时,所以我在这里问大家。 能否请您解释一下为什么这种方法不起作用,以及解决此问题的方法。

TEST.BAT:

:: Sets the text and background color of the CMD window
color 0a

::=================================================================::
:: Minecraft Server #1                                             ::
::                                                                 ::
:: Window and Log name, replace after =                            ::
set mc1=FTB 1.6.4                                                  
::                                                                 ::
:: Your start command, Replace after =                             ::
set runmc1="C:\Game Host\mc_ftb_monster-1.6.4\ServerStart.bat"     
::=================================================================::

::=======================::
::   End of variables    ::
::=======================::

:: This will keep the window clean and easy to read
@echo off 

:: Sets the title of the window
title Utility Launcher 1.0

:: This variable takes you back to the main screen
:begining

:: Clears the window incase there is anything there
cls

:: Prints to the window what we are doing

echo Server Utility Launcher 1.0 has been started!
echo.
echo *************************************************
echo To close this Utility Launcher, close this window
echo *************************************************

echo 1. Start FTB 1.6.4
echo.

set /p a=


IF %a%==1 echo Starting %mc1%
cd "C:\Game host\mc_ftb_monster-1.6.4\"
start %runmc1%
pause
goto begining

ServerStart.bat:

cd "C:\Game host\mc_ftb_monster-1.6.4"
java -Xms2048m -Xmx2048m -XX:PermSize=128m -jar "FTBServer-1.6.4-965.jar"   nogui
pause

只需从批处理文件的命令行中删除“ nogui”

您正在访问相对于正在执行它的文件夹的jar文件。

在您的ServerStart.bat中尝试

java -Xms2048m -Xmx2048m -XX:PermSize=128m -jar "C:\Game Host\mc_ftb_monster-1.6.4\FTBServer-1.6.4-965.jar" nogui

因此,如果执行ServerStart,它将在C:\\ users \\ username \\ desktop \\ FTBServer-1.6.4-965.jar中查找该jar文件,但找不到该文件。

为了确保Minecraft FTB服务器不会在桌面上创建关卡文件,您必须在java命令之前添加以下行。

cd "C:\Game host\mc_ftb_monster-1.6.4"

因此,如果您希望将其限制在目录中,那么总的来说是:

 cd "C:\Game host\mc_ftb_monster-1.6.4"
 java -Xms2048m -Xmx2048m -XX:PermSize=128m -jar "FTBServer-1.6.4-965.jar" nogui

编辑

尝试以此替换最后几行:

IF %a%==1 echo Starting %mc1%
cd "C:\Game host\mc_ftb_monster-1.6.4\"
cmd /C %runmc1%
pause
goto begining

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM