This How-To is deprechated, i have no idea if it would still work.
I wanted to have a minecraft server that runs as windows service. I think there a some cases where this might be useful. My goal was to have the server running while i was logged off. I now have two servers running on the same machine and it works like a charm.
Before we begin, you have to download the following files:
This tutorial won't cover how to set up java, but i think you'll figure that out. At first you have to create a folder where your server (or servers) will be stored.
I, for example, created the folder C:\Program Files (x86)\Minecraft\Server1. Now move the minecraft_server.jar there. Extract the files of yajsw-beta-10.6.zip into a subdirectory called yajsw.
In the next step we have to create a batchfile that starts the server with some parameters. Open your favorite text editor and type in the following:
@ECHO OFF
"C:\Program Files (x86)\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -cp "C:\Program Files (x86)\Minecraft\Server1\minecraft_server.jar" net.minecraft.server.MinecraftServer nogui
PAUSE
Save this as run.bat in the Server1 folder. The first two parameters define how much memory is used for the server (where -Xms is the initial memory size and -Xmx is the maximum size). Never put in more memory than your server has. The -cp option defines the java classpath which points to the minecraft_server.jar. There are some tutorials that use the -jar option instead, but this didn't work well with yajsw (You'll get a wrong classpath error).
You now should have the following structure:
..\Server1\yajsw\...
..\Server1\minecraft_server.bin
..\Server1\run.bat
Now start the run.bat (via terminal or double-click on it). On the first run the server generates the spawn-area and several folders appear in the servers directory.
Go to the Task-Manager via CTRL-ALT-DEL and go to the "Processes" tab. Go to the "View -> Select columns..." menu and activate the PID column. Now select the process called "java.exe *32". If you have more than one process with that name, try to shut down all other java services temporary. You'll need the Process ID of this java process.
Now go (via commandline) to
C:\Program Files (x86)\Minecraft\Server1\yajsw\bat
and Enter
> genConfig.bat <pid>
(with the process ID you got from the taskmanager in the step above).
The yajsw will now generate a config file.
Now open the created wrapper.conf in the yajsw/conf directory with your favourite text editor. The file might be empty if you did something wrong :( Then you should try to do the previous steps again.
If this is your first or only server you only have to change the following things:
Go to the line with
[...]
# Allow the service to interact with the desktop.
# wrapper.ntservice.interactive=false
# wrapper service user. only for windows. on *nix system this is root.
# see also wrapper.app.account
#wrapper.ntservice.account=
#wrapper.ntservice.user=
and uncomment the wrapper.ntservice.user= line.
Enter a valid username on your Windows 2008 installation. Please don't use the Administrator account, it's a security risk ;)
After this line you'll have to add wrapper.ntservice.password= with the user's password.
There are some options that are optional. You might want to change the Service name:
#********************************************************************
# Wrapper Windows Service and Posix Daemon Properties
#********************************************************************
# Name of the service
wrapper.ntservice.name=MC Server 1
# Display name of the service
wrapper.ntservice.displayname=MC Server 1
# Description of the service
wrapper.ntservice.description=MC Server 1
If this is the second (or more) Minecraft server on your machine, you'll have to change the line
#********************************************************************
# Wrapper System Tray Properties
#********************************************************************
# enable system tray
wrapper.tray = true
to wrapper.tray = false or else the next step won't work.
To test the config you have to go to the yajsw/bat directory (via commandline) and enter the following:
> runConsole.bat
If the server starts (the log is hard to read, but you'll find some of the output you saw when you started the run.bat on the previous steps) you have done everything right.
To install the service run the installService.bat in the yajsw/bat directory. Now the service should appear on the Windows Services screen (you'll get there via Start --> Run... --> services.msc).
My server was called "MC Server 1" in the wrapper.conf, so this is what appeared on my services screen.
Select the server and click on the "Start the Service" link in the upper left corner.
The server should change its status to "Running". It should stay that way, if not, you did something wrong ;)
To make sure the Windows firewall lets the minecraft traffic pass through, you have to add the Minecraft port to the whitelist. Normally this is port 25565 but this depends on your server.properties file in the servers root directory. If you use multiple servers you have to use a different port for every server.
The following pages helped me with creating this tutorial:
Created in 2011 by bitstacker