My java program was written on a windows machine and I am trying to get it installed and running on a Ubuntu 10.04 machine. I have created a .tar.gz file with myProgram.jar in it as well as 5 supporting library .jar files in a lib folder. Where do I put these files? Do I need to extract it on the Linux machine to a usr/bin folder? Does the shell script go inside the tar.gz? I have read that if you write the shell script on a windows machine you can have issues once you move it to the Linux machine, so I am writing the shell script on the Linux machine using gedit. I am just not sure what to do next.
So far in my script I have,
#!/bin/bash
java -jar myProgram.jar
I am going to try and extract the tar.gz file to the usr/bin directory and see if it runs.
Any suggestions or help would be greatly appreciated.
Thanks in advance,
Ray
Your question is quite “broad” :). I hope you find the following useful.
Do not extract the files to /usr/bin. See e.g. http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard on where and where not to put files on a *nix system.
cd /opt/yourProgramto have the proper working directory for your program before you invokejava./usr/binor better in/usr/local/binpointing to your script. Do this as last step after everything else is working.In your shell script you’ll have to add the other jars to the classpath e.g.
java -cp lib/some.jar:lib/other.jar -jar myProgram.jaror
java -cp lib/some.jar:lib/other.jar:myProgram.jar com.acme.ClassContainingMainRecommended practice: Add
set -eat the very beginning of your scriptAs you already mentioned it’s considered harmful to edit a shell script using a windows editor. The reason is that the windows editor will encode line-breaks (i.e. you hit the Return key) differently. This will make bash puke 🙂