0

I am trying to execute a jar by using java -jar test.jar. However, when I keep the jar name in a variable e.g

$a = "test.jar"

And try the execution using java -jar $a, it gives me an error

ERROR: Unable to access jarfile test.jar
Vivek Kumar Singh
  • 3,223
  • 1
  • 14
  • 27

1 Answers1

-2

Error meassage is quite clear, java cannot access the file: check whether you're launching this command in correct directory (where the .jar is located) and your powershell process has permissions to access it.

  • I have mentioned that when i execute a jar successfully by giving the jar name. It only fails when the jar name is stores in a variable and then executed. It is pretty evident that location is not the reason for the failure. – Smruti Chikali Feb 06 '18 at 04:54
  • Looks like this is fairly common problem, not only when launching .jar from PS: [link](https://stackoverflow.com/questions/11943948/what-causes-unable-to-access-jar-file-error) – Petr Snizek Feb 06 '18 at 06:44