0

I prefer Windows Power Shell because of the history lookup, but I get this error:

PS C:\Users\Me\Documents\Learn\Maven> "C:\Program Files\Java\jdk-11.0.10\bin\jar.exe" tvf my-webapp/target/my-webapp.war
At line:1 char:49
+ "C:\Program Files\Java\jdk-11.0.10\bin\jar.exe" tvf my-webapp/target/ ...
+                                                 ~~~
Unexpected token 'tvf' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

So I have to run it in a command window:

C:\Users\Me\Documents\Learn\Maven>"C:\Program Files\Java\jdk-11.0.10\bin\jar.exe" tvf my-webapp/target/my-webapp.war
    94 Sun May 02 10:28:44 CDT 2021 META-INF/MANIFEST.MF
     0 Sun May 02 10:28:44 CDT 2021 META-INF/
     0 Sun May 02 10:28:44 CDT 2021 WEB-INF/
     0 Sun May 02 10:05:22 CDT 2021 WEB-INF/classes/
     0 Sun May 02 10:28:44 CDT 2021 WEB-INF/lib/
    52 Sun May 02 09:59:26 CDT 2021 index.jsp
  2529 Sun May 02 10:28:44 CDT 2021 WEB-INF/lib/my-app-1.0-SNAPSHOT.jar
358085 Mon Mar 01 12:30:10 CST 2021 WEB-INF/lib/log4j-1.2.12.jar
   215 Sun May 02 09:59:26 CDT 2021 WEB-INF/web.xml
  2569 Sun May 02 10:27:34 CDT 2021 META-INF/maven/com.mycompany.app/my-webapp/pom.xml
   103 Sun May 02 10:28:44 CDT 2021 META-INF/maven/com.mycompany.app/my-webapp/pom.properties
likejudo
  • 2,946
  • 6
  • 45
  • 90
  • If you try with [`Start-Process`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7.1#example-7--specifying-arguments-to-the-process) does it work? `Start-Process "C:\Program Files\Java\jdk-11.0.10\bin\jar.exe" -ArgumentList "tvf my-webapp/target/my-webapp.war"` – Santiago Squarzon May 02 '21 at 16:21
  • In short: An executable path that is quoted or contains variable references must - for syntactic reasons - be invoked with `&`, the [call operator](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Operators#call-operator-); see [this answer](https://stackoverflow.com/a/57678081/45375) to the linked duplicate for details. – mklement0 May 02 '21 at 18:29
  • 1
    @SantiagoSquarzon, the only problem is the absence of `&` in the call. While use of `Start-Process` would bypass the original problem, `Start-Process` isn't appropriate for calling console applications. – mklement0 May 02 '21 at 18:30

0 Answers0