• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Bat file to run Java program  RSS feed

 
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
 
Marshal
Posts: 60703
189
  • 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.
 
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: 60703
189
  • 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!