3

First, I know it's possible to unzip a WAR file using jar in command line.

The problem is that on the target machine, there is no JDK installed, only the JRE. And we can't rely on Windows to unzip the file because it does not support well long path.

How it's possible to unzip a WAR file in command line when you only have the JRE installed?

Jonathan Anctil
  • 1,025
  • 3
  • 20
  • 44

2 Answers2

4

WAR file is just a ZIP file, you can unzip it using any Zip tool (like 7-Zip). If you don't have an access admin account, you can just download portable version of any zip archive, which doesn't require admin password.

Nelala_
  • 301
  • 2
  • 9
  • 1
    I can't assumed that there is a third-party unzipping tool like 7-Zip on the server. With the help of @SubOtimal, I've found a solution. – Jonathan Anctil Apr 19 '16 at 19:09
1

Just for the record I will share my solution that I've got from this answer.

I point in my question that I had also a problem with long path, a problem that I've solved with New-PSDrive, a function that let you map a temporary drive. I've only mapped a temporary drive on the working folder where I unzip stuff.

function Unzip-File($file) {    
    $path = [io.path]::GetDirectoryName($file.FullName)
    $filename = [io.path]::GetFileNameWithoutExtension($file.FullName)
    $targetPath = Join-Path $path $filename;

    # Check if the directory exists.    
    if(Test-Path $targetPath) {
        # Remove the directory before unzipping.
        Remove-Item $targetPath -recurse
    }

    # Unzip file.
    Add-Type -A System.IO.Compression.FileSystem
    [IO.Compression.ZipFile]::ExtractToDirectory($file, $targetPath)
}
Community
  • 1
  • 1
Jonathan Anctil
  • 1,025
  • 3
  • 20
  • 44