简体   繁体   中英

Command line arguments are not passed in Windows 7 - Java

I am running a executable jar using batch which expects command line arguments.

ECHO OFF  
java -jar myjar.jar %1 %2 %3 %CD% 
PAUSE 

I checked the code on one windows system and works fine. I am running it on another windows 7 system, but the command line arguments are not passed to the jar. The args.length gives me 0. I have checked the following:

C:\Users> assoc .jar  
.jar=jarfile
C:\Users> ftype jarfile
jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*  

I have also tested a simple batch file to ECHO a command line argument, and it works fine. I accepts the argument and prints it.
How can I fix this?

It is resolved. I think the answer might seem to be very silly, but since I posted the question so I would just go ahead. So the problem was that I was running Java Runtime Environment, it got resolved when I installed Development Kit instead. But what I'm quite confused about is that, I installed the Runtime Environment on the other Windows 7 system and it worked fine, why did it didn't work and needed JDK instead for this system running windows 7 as well. Thank you everyone for taking time. I would really appreciate it if anybody knows why did it act this way and just mention it.

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