Aaron Yodaiken
Aaron Yodaiken

Reputation: 19551

bash script to run command-line java program

Currently I run my program like this:

java program arg1 arg2 arg3...

There are a variable number or arguments. Is there some BASH script or something I can package with my program to allow me to run it just like

program arg1 arg2 arg3

and continue to allow me to have variable arguments.

I just care about Unix systems.

I'm sorry for this simple question: I'm a Java developer, not a BASH scriptor.

Upvotes: 2

Views: 19258

Answers (2)

Paŭlo Ebermann
Paŭlo Ebermann

Reputation: 74750

Here:

#!/bin/bash

java program "$@"

Or if you want the bash to exit when java is called, use this:

#!/bin/bash

exec java program "$@"

(This replaces the bash process with the java process instead of waiting until java returns.)

Upvotes: 10

chrisaycock
chrisaycock

Reputation: 37930

Just use an alias:

alias program='java program'

Upvotes: 2

Related Questions