0

I would like to make a shortcut for a minecraft server.

I want it to launch cd Minecraft && java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

I would also like to keep the terminal open so i can see the logs.

Can anyone help please?

  • You mean a keyboard shortcut? If you want it in a terminal, then maybe an alias would do? – Zanna Feb 17 '17 at 21:22
  • Do you just want a shorter command to run in the terminal? Or do you want to make an entry in the Launcher? – insert_name_here Feb 17 '17 at 21:25
  • @insert_name_here I would like a desktop icon i can double click that will launch terminal and execute those commands, although a shorter command would also work – Jack Feb 17 '17 at 21:52
1

You can make an alias for the command using the alias command:

alias 'start-minecraft-server'='cd Minecraft && java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'

Now the command start-minecraft-server will execute those commands. You should probably use an absolute path though, since otherwise it'll only work if you're in the right directory:

alias 'start-minecraft-server'='cd /path/to/Minecraft && java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'

Aliases are lost when you close your terminal, though. To make it permanent, you can add that alias command to ~/.bash_aliases, which is read automatically when you start the terminal on Ubuntu.


You can also put a shortcut on the desktop. To do this, you will have to put a .desktop file in ~/Desktop (for example, ~/Desktop/minecraft_server.desktop). Here is an example that should do what you want:

[Desktop Entry]
Version=1.0
Exec=bash -c 'cd /path/to/Minecraft && java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'
Name=Minecraft Server
Comment=Start Minecraft server
Terminal=true
Type=Application
Categories=Application;Network;

(replace /path/to/Minecraft/ with the full path to the Minecraft directory)

  • When I execute the shortcut nothing happens.The GUI asked how I want to open it, I choose execute in terminal. It flashes open then closes, there server doesn't run in the background either – Jack Feb 18 '17 at 4:00
  • @Jack Odd. Try adding ; read before the second ' in the Exec line to keep the terminal open so you can see if there are any error messages. – insert_name_here Feb 18 '17 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.