Reputation: 761
I have written a Java program that takes in arguments and then executes. I pass in these arguments from the command line (I am on a Macbook Pro using Terminal, using the bash shell). Let's say the name of my program is prgm. I want to be able to say "prgm " from any directory in the shell and then have that program execute. So I figure I need to write a bash script to reference the Java files and take in arguments, and put that bash script somewhere in my PATH. Where do I put the bash file, and where do I put my Java files? Also, am I right to assume that I only need the .class (binary) Java files?
Upvotes: 2
Views: 384
Reputation: 5305
Step-by-step:
myjavaprog
.myscript
.myscript
is calling myjavaprog
using absolute path and the desired arguments.echo $PATH
and you will see a bunch of paths: /some/path1:/some/other/path2:...
echo $PATH
.bash myscript
. See the execution of myjavaprog
.Tips:
/usr/
or even in your $HOME
directory (and add that location to your PATH
)PATH
variable.Upvotes: 1