Java / Minecraft "Error: Could not find or load main class –Xms1024M"

Solution 1:

Specifying RAM


The issues by not specifying RAM is pretty simply that your Minecraft server won't have enough RAM reserved for it, causing it to crash. Have you tried putting the RAM commands at the end, like so:

java -jar minecraft_server.jar -Xmx8192M

Be sure to adjust the RAM to your limits. Note, additionally, that you do not need to specify -Xms in your arguments. Be sure to also not use sudo, as that opens up the possibility for system compromise.


Using Minecraft in the background


You can run Minecraft in the background in many different ways. I've listed a few below as an example.

Method 1: screen

You can run a Minecraft session in the background using a nifty utility known as screen. You can do this by just running the screen command, followed by your start command. Afterwards, just press Ctrl + A followed by D. You'll come back to a terminal. To resume your screen session, just run screen -r.

Most people prefer screen because you can go back and access the console at any time.

Method 2: bg/fg

After your Minecraft server has started, press Ctrl+Z on your keyboard. From there, type bg. Your Minecraft server will be running in the background.

Note that I have not personally tested it, so YMMV.

Method 3: nohup

Prepend your start command with the nohup command. After your Minecraft server has started, just close your SSH session. The server will keep running.

Be careful using nohup though, because it will use up a LOT of hard drive space keeping its own logs. You can avoid this by appending >/dev/null 2>&1 to the end of the command.

Method 4: Initscripts

Initscripts are very complicated, but it lets your server auto-start/stop on boot or on manual invocation. Instructions are available online. There are many good methods, but they need to be tailored to your system.


Permission Errors


Your permissions problem is because Minecraft created all of its files as root. Therefore only root can access them. Fix this by running sudo chown -R $USER:$USER . in the Minecraft folder.

Source: Sysadmin for a Minecraft network

Solution 2:

Pay attention to case!

The m should be lower case, like so:

sudo java -Xms1024m -Xmx1024m -jar minecraft_server.1.9.2.jar nogui

Also, try putting the memory options at the end.