• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bat file to run Java program  RSS feed

 
Alok Panda
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Can some one provide me a sample bat file which can be invoked from the command line and start a java program which let us say does an addition operation accepting parameters from command line.
Appreciate all your help.

Regards,
Alok
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very similar query came up very recently. See whether this thread is any help.
 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put in your app.bat file something similar to:


(if you want to start from .jar)


(if you want to start compiled class)

and call it with:



15 14 will be put in your command instead of %1 and %2 and you'll have them in String[] args.

Of course, you should have JAVA_HOME environment variable set up before using your .bat file.

I hope that this helps.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would probably work, but on the thread I quoted earlier, Rob Prime suggests javaw will give better results.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!