Ubuntu: How do you run a java program from a bash script?


I am trying to run a minecraft server from a "run.sh" script. So far I have this:

#!/bin/sh  java -Xms512M -Xmx2048M -jar minecraft_server.jar nogui  

I'm running the script from the same directory as the minecraft_server.jar, and it does nothing. I want it to open a terminal window that is running the java program. I am new to Linux so I'm sure I'm doing something stupid, any help would be appreciated.


If the problem is that running the script doesn't show a terminal window, the solution depends on the window manager you're using. Gnome as well as KDE allow to edit properties of desktop shortcuts on a right-click and setting a option like "run in terminal" there.

Another way is to edit the desktop configuration file manually: you can find them in the Desktop subdirectory of your home dir. Just add a line with Terminal=true to the desktop configuration file that should run the server.


Why are you using echo? That just prints the rest of the line as a sequence of literals to the terminal.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »