I have a Windows batch file to run my Java app, so this looks like:
RunJavaPgm.bat
java -classpath lib\* com.blah.MyClass %*
So this works perfectly well, I can pass through any number of parameters to my main method by doing something like
RunJavaPgm Param1 Param2
Now the problem I've hit is that I need to define some system properties, but if I try to do something like
RunJavaPgm Param1 Param2 -DMyProperty=MyValue
then it doesn't work - its passing that -D value to my main method. Putting " around it makes no difference. The reason being that, if you just type "java' on the command line, it tells you what the syntax is supposed to be:
java [-options] class [args]
So any -D parameters need to go before the classname, and any main method parameters need to go after the classname. Making the batch file intelligent enough to examine the value of every parameter passed to it and splitting them up in that way would seem very difficult to do, can anyone think of any clever alternatives?
Many thanks!