Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 866.5k
  • 205
  • 1.8k
  • 2.3k
Source Link
Pete
  • 163
  • 1
  • 8

How do I install multiple java command-line programs?

I have a bunch of java command-line programs I've written and would like to install for all users.

Building with NetBeans, I get a /dist directory which contains myprog1.jar and a /libs directory with all the necessary libraries. The usual method to run is to go there and java -jar my.jar -options.

So what I'd like to do is just type myprog1 -options from anywhere and have it run.

The method I have thought of is:

  1. Create /opt/myjava/myprog1 which contains myprog1.jar and its /libs.
  2. Create a bash script myprog1 in /usr/local/bin which simply redirects all of the command line args to java -jar /opt/myjava/myprog1/myprog1.jar

I'm not too keen on bash scripting... if this is a reasonable method, what would that script look like, given that each program has a variable number and order of arguments? Does the script have to also worry about standard Unix bits such as output redirect > and pipes |?