Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My question is this.

I have a jar file that I want to be able to run from command line with a simple command. So in my ~/.bashrc file I created an alias like so:

alias selenium='java -jar selenium-server-standalone-2.31.0.jar'

the jar file is in here: /usr/local/bin

and I have /usr/local/bin in my path variable. My understanding is that because it is in my Path variable I can run it from anywhere, however if I open a terminal and type:

selenium

I get this:

Error: Unable to access jarfile selenium-server-standalone-2.31.0.jar

so the alias is working, but it cant access the file. If I change directory to /usr/local/bin and type selenium again it works

Any reason why I can't run this from anywhere?

Also, what is the purpose of /usr/local/bin folder. IS this where I should put programs I want to run?

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You are not running the .jar file by itself. Instead you run java and pass the name of the jar file as a parameter. If you pass only the name of the file but not a full path the system will assume the file is in your current directory and if it is not you will get the error you mentioned. You should pass the full path after the -jar flag and then you can run your alias from any directory.

share|improve this answer
    
Good to know. Thanks for the feedback. –  Kevin Bradshaw Mar 23 '13 at 15:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.