Reputation: 2664
I am curious if I can take a .jar
file and somehow add it to my classpath
so that I can run it from any directory. For example, let's say I have a .jar
located at /home/setup/someJar.jar
. Is there a way I can run this from another directory (preferably any) so that I do not have to navigate back to /home/setup/
whenever I want to run it?
I tried adding the path to my .bash_profile
file by adding :/home/setup
to the PATH=
line, but didn't work.
Upvotes: 2
Views: 508
Reputation: 11310
It's possible but not so easy. you have 3 possiblities
Make an alias or symbolic link (create symbolic link)
Start it as deamon
start it as service (create service)
after ready the information above
you can start it like this
service [yourservice] start|stop|restart
Upvotes: 2
Reputation: 18860
I think you probably want an 'alias'.
http://www.linfo.org/alias.html
alias myJarShortcut="java -jar /direct/path/to/nameOfYourJar.jar"
Add this to your .bash_profile and it will be available every time you boot up.
Upvotes: 3
Reputation: 879
You could create a bash script that execute your .jar file in the directory of your choice, with of course the right path to your .jar file.
Upvotes: 1