-2

I have created a java program for image processing using eclipse. But I need to create a batch file for giving different input..how can be achieve this?

  • your question is not clear? why are you using batch file here? and would the real thing you want is [`How to execute batch file using java`](http://stackoverflow.com/questions/1421143/how-to-execute-a-batch-file-from-java)? – Freak Apr 12 '13 at 11:12
  • Do you mean that you have a java program, and you want to write a batch file to execute it with different image files as the input? – Alan Apr 12 '13 at 11:28

3 Answers3

2

You need to start by learning how Java works outside the comfort of the IDE.

You can read this article, for instance: http://www.sergiy.ca/how-to-compile-and-launch-java-code-from-command-line/

Or just google how to run your Java program from the command line.

After that, you can create a simple batch to run your program, as you would do manually from the prompt.

That article should cover how to pass arguments to your program, and from there, it should be fairly easy to modify your bash file to pass the arguments to the program.

pcalcao
  • 15,789
  • 1
  • 44
  • 64
1

you even do not need to write a batch file.
You can start your Jar-File with some parameters. In your main-method you can read your parameters from the args array.

For example:

You can start your program from the command prompt with:

java -jar yourJar.jar hello world

In your main-method you can read the parameters like this:

public static void main(String[] args)
    {
        String parameter1 = args[0];
        String parameter2 = args[1];
    }

So parameter1 has the value hello, parameter2 has the value world.

Obl Tobl
  • 5,604
  • 8
  • 41
  • 65
0

Take a look at ant http://ant.apache.org you can find info about passing args to ant in this question here How do I pass an argument to an Ant task?

Community
  • 1
  • 1
gheese
  • 1,170
  • 1
  • 11
  • 17