How to extract only one file from war file?
The -j
flag is exactly what you need:
unzip -j test.war "*test.properties*"
From the docs:
-j
junk paths. The archive's directory structure is not recreated; all
files are deposited in the extraction directory (by default, the
current one).
How to unzip a WAR file in command line
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)
}
How to extract .war files in java? ZIP vs JAR
If you look at the JarFile API you'll see that it's a subclass of the ZipFile class.
The jar-specific classes mostly just add jar-specific functionality, like direct support for manifest file attributes and so on.
It's OOP "in action"; since jar files are zip files, the jar classes can use zip functionality and provide additional utility.
Seeing contents of war file without extracting
The t
option to the command line jar
program will list the contents of a jar (or war) file, e.g.:
$ jar tf the-file.war
Related Topics
Listview Is Blank While Using Getfilter Function
Android Studio Debugger Highlights the Wrong Lines
How to Find Java Heap Size and Memory Used (Linux)
Library to Read/Write Pbxproj/Xcodeproj Files
Differencebetween Swing and Awt
Why Java Inner Classes Require "Final" Outer Instance Variables
Java Datetimeformatterbuilder Fails on Testtime
Jpql Create New Object in Select Statement - Avoid or Embrace
What's the Syntax to Import a Class in a Default Package in Java
How to Synchronize a Static Variable Among Threads Running Different Instances of a Class in Java
Android: How to Stretch an Image to the Screen Width While Maintaining Aspect Ratio
Why I Cant Use the Populateviewholder Override Method
Ubuntu: Openjdk 8 - Unable to Locate Package
Ruby and Duck Typing: Design by Contract Impossible
Import Maven Dependencies in Intellij Idea
Calling One Jframe from Another Using Timer Without Any Buttons
How to Exclude Some Concrete Urls from <Url-Pattern> Inside <Filter-Mapping>