This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I have one java application(which has main method). Generally, if we want to pass parameter to application using command line, we type java <Name of Application> <Parameters> Right now, in our project we using batch file which we add some classpath and use java keyword to run an application. Now if I use batch file, how we can pass parameter to an application??? We don't want admin to open the batch file to pass parameter to an application. Thanks, Angela
in your batch file do the following: java MyClass %1 %2 %n where n is the number of parameters you expect to pass eg. you java class is called MyApp and it takes 2 parameters your batch file (say its named runme.bat) would look like this: java MyApp %1 %2 Then whoever is running it would issue the command: runme.bat "parameter1" "parameter2"
Your other choices are to add a small Dialog at the beginning of your app to take in those parameters before the rest of your app fires up, OR to have the main method ask for some input from the console, which means that the user must know to go to the DOS window to enter those parameters.