Java / Minecraft "Error: Could Not Find or Load Main Class –Xms1024M"

Java / Minecraft "Error: Could Not Find or Load Main Class –Xms1024M"

I am not a Linux pro nor a Java pro, but I am setting up a Minecraft server on Ubuntu 16.04. System has 8GB RAM.

I followed all the directions for setting up the server (which is very simple) but when I ran the command:

sudo java –Xms1024M -Xmx1024M -jar minecraft_server.1.9.2.jar nogui

I got this:

Error: Could not find or load main class –Xms1024M

I then simply ran (after about 1 hour of hacking around trying to install different JREs): sudo java -jar minecraft_server.1.9.2.jar nogui and it worked.

What is the difference and what are the possible issues by not specifying RAM?

Additionally, what is a good practice for starting up the Minecraft server via SSH and letting it run in the background after disconnecting?

Edit:

When running java -jar minecraft_server.1.9.2.jar nogui I am seeing this output:

2016-05-08 14:30:35,683 ERROR Cannot access RandomAccessFile {}) java.io.FileNotFoundException: logs/latest.log (Permission denied)
2016-05-08 14:30:35,684 ERROR Unable to invoke method createAppender in class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

Followed by an endless list of these:

at kx.a(SourceFile:44) [minecraft_server.1.9.2.jar:?]
at kx.b(SourceFile:54) [minecraft_server.1.9.2.jar:?]
at kx.a(SourceFile:44) [minecraft_server.1.9.2.jar:?]
at kx.b(SourceFile:54) [minecraft_server.1.9.2.jar:?]
at kx.a(SourceFile:44) [minecraft_server.1.9.2.jar:?]
at kx.b(SourceFile:54) [minecraft_server.1.9.2.jar:?]
at kx.a(SourceFile:44) [minecraft_server.1.9.2.jar:?]
at kx.b(SourceFile:54) [minecraft_server.1.9.2.jar:?]
at kx.a(SourceFile:44) [minecraft_server.1.9.2.jar:?]
at kx.b(SourceFile:54) [minecraft_server.1.9.2.jar:?]
2

2 Answers

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.


Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.