简体   繁体   中英

Cant open Jar file which is open using a batch which is opened using another batch file

I am trying to open a batch file which is opened by another batch file which is supposed to launch my jar file.

This is the line of the batch file which I use to open my ServerStart.bat to launch my jar file. (test.bat which is located on my desktop.)

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

This is the ServerStart.bat

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

Then I get this: http://i.imgur.com/MhV4xC7.jpg

I have spent hours all over Google so I'm here to ask you all. Can some please explain why this doesn't work and a way to fix this issue I'm having.

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”

You are accessing the jar file RELATIVE to the folder you are executing it.

Try this in your 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

so if you execute your ServerStart it will look for the jar in C:\\users\\username\\desktop\\FTBServer-1.6.4-965.jar where it wont find dit.

To make sure the Minecraft FTB server doesnt create the level files on your desktop you must add the following line before the java command.

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

So in total your bat would be if you want it confined to your directory :

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

EDIT

try replacing your last lines with this:

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

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.

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