Re: Batch file params
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Aug 2005 13:51:40 +0100
Andrew Thompson wrote:
On 27 Aug 2005 04:40:52 -0700, iblamemicrosoft@xxxxxxxxx wrote:
I know how in html files you can simply go:
<param name="number" value="1">
but how can you replicate this in a batch file?
For an application, you can provide arguments on the command line when you invoke Java, like..
java TheMainClass arg1 arg2 arg3
From a programmer point of view it tends to be easier to pass arguments as properties. It's also a handy technique if you have lots of classes with main methods and your IDE can set properties for all of them.
java -Dnumber=1 -jar MyApp
String number = System.getProperty("number");
In 1.0 and from 1.5 you can also read environment variables through System.getenv.
#!/bin/bash export MYAPP_NUMBER=1 java -jar MyApp
String number = System.getenv("MYAPP_NUMBER");
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/java.html#options http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperty(java.lang.String) http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getenv(java.lang.String)
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- Follow-Ups:
- Re: Batch file params
- From: Andrew Thompson
- Re: Batch file params
- References:
- Batch file params
- From: iblamemicrosoft
- Re: Batch file params
- From: Andrew Thompson
- Batch file params
- Prev by Date: Re: Batch file params
- Next by Date: Re: Batch file params
- Previous by thread: Re: Batch file params
- Next by thread: Re: Batch file params
- Index(es):