I want to run a java program in Linux and change its working directory to a specific location. I’m a bit of a noob with Linux, so I need quite a bit of help. I managed to figure this much out:
java -jar program.jar
That will run the program in the working directory it chooses. Now I need to find a way to change the working directory. I think this computer is running UBuntu (or however you spell it) but I’m not sure. I’m also running on an account that has severely limited privileges.
EDIT (based on info given in asker’s comment below):
So, it seems like you just need a batch script to
cdinto its own directory before launching java.Something like this script should do it.
So, make sure it’s executable (
chmod +x minecraft.sh), then when you double-click it or run the script from any folder, it will treat the script’s folder as its working directory. More information can be found in SO questions like this one.I’m not going to install Minecraft, otherwise my life will disappear down a dark gaming hole 😉
Original answer:
say for desired working directory /x/y/z, and program.jar is in directory /a/b/c