Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Ubuntu-friend told me to testrun a Beanshell script by doing:

bsh #filename#

and when I told him that I don't know what bsh is nor have it he told me:

sudo apt-get install bsh

Being on a Mac I instead ran:

sudo port install beanshell

But still no bsh command available. A listing of the package content revealed a jar file named:


but when I try to run that with my script file a complete Window manager written in Java starts up (and does not run the script file btw). Now, clearly I am doing something wrong, I am sure there must be a way of running beanshell scripts on a mac terminal although it does seem more natural for the linux users. What am I doing wrong and what should I do to run that script?

share|improve this question

migrated from Sep 13 '11 at 1:58

This question came from our site for professional and enthusiast programmers.

If you want to know how to do it: java -cp /opt/local/share/java/bsh.jar bsh.Interpreter (apparently I am not allowed to answer) :( – jonalv Sep 12 '11 at 16:01
up vote 2 down vote accepted

First check that bsh.jar is on your CLASSPATH. If it is not, add it by running:

export CLASSPATH=$CLASSPATH:/opt/local/share/java/bsh.jar

Then run it like this:

java bsh.Interpreter filename

See the manual for more information.

share|improve this answer
yea even nicer. I got totally side tracked by the instructions to just run bsh filename... – jonalv Sep 12 '11 at 16:15
You could write a shell script called bsh consisting of java -cp /opt/local/share/java/bsh.jar bsh.Interpreter "$@". – Kevin Reid Dec 1 '11 at 3:45

For Mac OS X, someone has created a Beanshell installer.

share|improve this answer

Its even easier if you just drop the bsh.jar into your JAVA_HOME/jre/lib/ext directory. Then you only need to call it with: java bsh.Interpreter filename.bsh without needing to mess with the classpath.

share|improve this answer
I wouldn't recommend putting jars in JAVA_HOME/jre, because if you upgrade the JRE, you have to remember to copy yours jars into the new JRE. (also see…) – dogbane Dec 1 '11 at 8:25
In the case of beanshell, its just one jar, so its no problem. I usually have my shell script copy the jar into place if its missing and so i dont forget. – djangofan Dec 2 '11 at 0:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .