简体   繁体   中英

Input filename into jar from windows batch file

I want to input a file into my jar after it is executed from batch file.

I wrote the following batch code.

@echo off

 set path=%PATH%;C:\Program Files\Java\jre7\bin

 java -jar E:\ER\er_v.3.3.17.jar

The above code is working fine. However, after the jar file is executed I need to feed another file for it to run successfully.

I want something like this

@echo off

 set path=%PATH%;C:\Program Files\Java\jre7\bin

 java -jar E:\ER\er_v.3.3.17.jar

 echo E:\Run.xml

Can somebody help me with this?

Here you go. I tested this and it works.

@echo off
setlocal

:: if java.exe is not in %path%
for %%I in (java.exe) do if "%%~$PATH:I" equ "" (
    set "PATH=%PATH%;C:\Program Files\Java\jre7\bin;C:\Program Files (x86)\Java\jre7\bin"
)

echo E:\Run.xml| java -jar E:\ER\er_v.3.3.17.jar

This passes "E:\\Run.xml" to the stdin of java -jar etc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM