views:

105

answers:

2

Hi everyone,

I'm trying to write a batch script, this script is responsible to launch a jar with one parameters.

This parameter indicate to my jar wich property file to use in order to setup some configuration.

Then the script will zip the results produced by the jar and send them to a location. But in order to set the name of the zip file I would need to be able to read the property file directly from the batch, is there a way to do so ?

Thanks and regards,

F

A: 

Can you pass it on the command line as an arg and read it in your main() method ?

java {myclass} %PROP%

or as a Java property and read via System.getProperty() ?

java -DzipName=%PROP% {myclass}
Brian Agnew
A: 
@echo off
setlocal
set FN=filename
set TARGET=propertyname
FOR /F "tokens=1,2 delims==" %%A IN (%FN%) DO IF "%%A"=="%TARGET%" set FOUND=%%B
echo %FOUND%
Paul McKenzie