Change directory and execute file in one command

cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar should do it


I am answering this question again with some extension so that others may find this useful.

cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar

This command will do for sure. But after running this command, you will stay in /usr/local/bin/minecraft/ directory. And, if you are using this command in a bash script, all the later commands will be executed in this directory.

If you want to run the command in your desired directory and get immediately back to where you were, enclose the command with parenthesis, i.e.,

(cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar)