How to manually ‘install’ a command-line based Java application consisting of an executable and several auxiliary modules

installjavaterminal

I'd like to use Briss, a Java application for cropping pdf files. The application consists of a compressed folder containing several Java .jar files. Presumably one of them is the executable, and the others are auxiliary modules that the executable uses. The application has a GUI, but is run from the Terminal by running the following command line:

java -jar briss-0.9.jar

How can I 'install' this application so that I can run it by typing the above command in a freshly opened Terminal window?

One way to do it would be to dump all the .jar files inside /usr/local/bin, but I'd rather not pollute the bin folder with a horde of files, and also I'd like to keep the files together, so that, for instance, the application can be easily and cleanly 'uninstalled'.

Best Answer

Copy the files to somewhere static such as ~/Applications, then add the following to your profile:

alias briss="java -jar /path/to/briss-0.9.jar"

Then you can run ‘briss’ from Terminal from anywhere.

You may need to create ~/Applications if you haven't used it before. Upon creation, macOS automatically gives the folder the Applications folder icon. The location of your profile depends on your shell — the default macOS shell is bash and the profile is ~/.bash_profile.