Search code examples
minecraftminecraft-forge

How to access my minecraft server console?


I've installed , configured and launched my first minecraft server using this guide : https://www.minecraft.net/en-us/download/server

And I have a few questions :

  • How can I access the server console ?
  • Is it possible to interact with the server console from an external program ? Running on javascript ( node ) or maybe even java ? If so , could you give me any useful resources to read ?

Solution

  • The server.jar file is meant to be launched via the command line or by an script (which normally opens a command prompt).

    So, in order to get access to the console, you should launch it from the cmdline with the required arguments. The minimum is: "java -jar server.jar", although specifying a min memory size and max memory size is more than desirable in most cases.

    As for interacting with it with an external program, there are many ways. First one that comes to mind is writing a Spigot plugin (that's the base of most Minecraft servers nowadays) that allows you to interface with your server. Another way would be by making a pipe (if using Linux) between the server process and your "external program" process. You could also launch the server directly from the other program with some language functions, like exec in C.

    In unix there's a tool called "screen" which might help you. It's widely used in the Minecraft server community to keep servers running in the background.