Command line arguments are not passed in Windows 7 - Java

272 views Asked by At

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?

1

There are 1 answers

0
Tamaghna Guha Thakurta On

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.