How to set Minecraft server port from the CLI?

I can't seem to find an up-to-date and clear answer on this. I just want to run the Minecraft server JAR on a different port than the default 25565.


Solution 1:

You can change the port in the server.properties-file. You can find this file in the same directory as your server.jar is in. Edit this file like this: server-port=<new-port> (e.g. server-port=1337 to run the server on port 1337).

You can find a detailed documentation about the server.properties-file and the affected property here: http://minecraft.gamepedia.com/Server.properties

If you really want to change the port from cli you can use Bukkit and pass an argument -p=<new-port> to launch the server on a different port. It also overrides the server-port-property in the server.properties-file. (Source: CraftBukkit Source Code) Example: java -jar bukkit.jar -p=1337.

Hope it helps. :)