[英]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.