2

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.

2 Answers 2

10

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.)

Sign up to request clarification or add additional context in comments.

Comments

2

Just use an alias:

alias program='java program'

4 Comments

Since he wants to pass arguments, I doubt aliases can be used. A function would be needed.
@qwerty Arguments very much can be used with aliases. Try it yourself.
Common way of doing it, is using a batch file.
@gyger The OP is using bash in Unix. Batch files are for Windows.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.