RAZ Archiver is a desktop file compression application built in Java with a JavaFX user interface. Instead of relying on a single algorithm, it compresses every input using four competing strategies — RLE, LZW, Huffman, and a hybrid LZW + Huffman pipeline — then automatically stores whichever produced the smallest result.
Files are packed into a custom .raz archive format (with CRC32 integrity verification), and entire folders are compressed into a portable .raz.zip container. Decompression is fully lossless: the winning algorithm, original file extension, and a checksum are all embedded in the archive header, so any archive can always be restored to a byte-identical copy of the original.
- Adaptive multi-algorithm compression — RLE, LZW, Huffman, and LZW + Huffman are all executed; the best result wins automatically.
- Custom
.razarchive format — self-describing header with a magic number, algorithm name, original extension, original size, and CRC32 checksum. - Lossless, verified restoration — every decompressed file is validated against its CRC32 checksum before being written.
- File and folder support — compress a single file to
.raz, or recursively compress a whole folder into a.raz.zipcontainer that preserves the directory structure. - Modern JavaFX GUI — drag-and-drop zones, file/folder choosers, background processing (non-blocking UI), and a one-click "Download Result" flow.
- Compression analytics — a stats window reports original size, compressed size, the winning algorithm, and the achieved compression percentage.
- Corruption detection — invalid magic numbers or checksum mismatches are caught with clear errors (
Invalid .raz file!,Checksum mismatch — file corrupted!).
All algorithms implement a common abstract base class (CompressionAlgorithm) exposing compress(byte[]) and decompress(byte[]).
| Algorithm | Technique | Best Suited For |
|---|---|---|
| RLE | Replaces runs of repeated bytes with (count, value) pairs (max run length 255). |
Data with long repeated sequences, e.g. simple graphics, logs. |
| LZW | Dictionary coding: builds a dynamic dictionary of byte sequences (seeded with all 256 byte values) and emits fixed 16-bit codes; the dictionary resets at 65,536 entries. | Repetitive text and structured data. |
| Huffman | Variable-length prefix coding driven by byte frequency. The code tree is serialized (preorder: 1 = leaf, 0 = internal node) and embedded in the output. |
Data with a skewed byte-frequency distribution. |
| LZW + Huffman | Hybrid pipeline: LZW output is passed through Huffman coding for compounding gains. | Data that benefits from both dictionary and entropy coding. |
flowchart LR
A[Input bytes] --> B[RLE]
A --> C[LZW]
A --> D[Huffman]
C --> E[Huffman over LZW]
B --> F{Smallest output?}
C --> F
D --> F
E --> F
F --> G[.raz archive<br/>header + winning payload]
The compressor runs all four candidates on every input, compares their output sizes, and stores the smallest one. The winner's name is recorded in the file header so decompression knows exactly how to reverse it.
Every archive is laid out as:
+-----------------+---------------------------+---------------------------+
| Header Length | File Header (variable) | Compressed Payload |
| (4 bytes, int) | | (variable) |
+-----------------+---------------------------+---------------------------+
The header itself contains:
| Field | Type | Description |
|---|---|---|
| Magic number | 4 bytes | 'R' 'A' 'Z' '!' — identifies a valid archive |
| Pipeline name | UTF string | Winning algorithm (RLE, LZW, Huffman, or LZW+Huffman) |
| Original extension | UTF string | e.g. .txt, .png — used to restore the file |
| Original size | 8-byte long | Original file size in bytes |
| CRC32 checksum | 4 bytes | Checksum of the original data, verified on decompression |
Folder archives: each file inside the folder is compressed individually as its own .raz entry, and all entries are written into a standard ZIP container named <folder>.raz.zip, preserving relative paths. On extraction, the original directory tree is rebuilt under restored_<folder name>/.
2nd-Semester-Project-SP26-JAVA-main/
├── File Compressor/ # Maven project
│ ├── pom.xml
│ └── src/
│ ├── RAZ Archiver LOGO.jpg # UI assets
│ ├── raz_icon.png
│ ├── File Icon.png
│ └── main/java/com/compressor/
│ ├── algorithm/
│ │ ├── CompressionAlgorithm.java # Abstract base class
│ │ ├── RLE_Compressor.java # Run-Length Encoding
│ │ ├── LZW_Compressor.java # Lempel-Ziv-Welch
│ │ └── Huffman_Compressor.java # Huffman coding
│ ├── core/
│ │ ├── MultiLevelCompressor.java # Adaptive pipeline + archive I/O
│ │ └── FileHeader.java # .raz header (serialize/deserialize)
│ ├── gui/
│ │ └── MainWindow.java # JavaFX application entry point
│ └── io/
│ └── FileHandler.java # File read/write helpers
└── Project Material/
├── Complete Guide.pdf
└── UML Diagram.png
| Dependency | Version |
|---|---|
| JDK | 25 or later |
| Maven | 3.x (or the bundled Maven in your IDE) |
| JavaFX SDK | 21+ (required on the module path at runtime) |
- Open the
File Compressorfolder in IntelliJ IDEA. - Make sure Project SDK is set to JDK 25 (
File → Project Structure → Project). - Ensure the JavaFX SDK is available and added to the classpath/module path (IntelliJ's bundled JavaFX setup or a locally installed SDK).
- Run
MainWindow.main()(src/main/java/com/compressor/gui/MainWindow.java).
Note: the logo and icon assets are loaded from the
src/directory at runtime, so launch the application with the project root as the working directory (the IntelliJ default).
cd "File Compressor"
mvn clean compileThe bundled
pom.xmldoes not declare JavaFX as a Maven dependency — the GUI is currently resolved through the IDE/SDK setup. To build and run purely with Maven, add the JavaFX artifacts:<dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>21</version> </dependency>together with the
javafx-maven-plugin:<plugin> <groupId>org.openjfx</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>0.0.8</version> <configuration> <mainClass>com.compressor.gui.MainWindow</mainClass> </configuration> </plugin>then launch with
mvn javafx:run.
- Launch the application — the RAZ Archiver window opens.
- Compress:
- Drag and drop a file or folder onto the left panel (or use Select File / Select Folder).
- Click COMPRESS — processing runs in the background.
- Click View Compression Stats to see original size, compressed size, the winning algorithm, and the compression percentage.
- Click Download Result and choose where to save the
.razfile (or.raz.zipfor folders).
- Decompress:
- Drag and drop a
.razfile or a.raz.ziparchive onto the right panel. - Click DECOMPRESS — the original data is restored and integrity-checked.
- Click Download Result to save the restored file (or folder tree) anywhere on disk.
- Drag and drop a
- Polymorphic design — a single abstract
CompressionAlgorithmcontract makes it trivial to add new algorithms; the pipeline treats them uniformly. - Self-describing archives — decompression requires no user input; everything needed (algorithm, extension, size, checksum) travels inside the header.
- Data integrity — CRC32 checksums guard against silent corruption; mismatched data is rejected with an explicit error.
- Responsive UI — all compression work executes on a JavaFX
Taskbackground thread, with results marshalled back to the UI viaPlatform.runLater(), keeping the window responsive on large files. - Memory-conscious I/O — streaming ZIP input/output for folder operations and buffered byte streams throughout.
Additional project documentation is available in the Project Material folder:
- Complete Guide.pdf — full project walkthrough and report.
- UML Diagram.png — class diagram of the application architecture.
This project was developed by two contributors:
- Muhammad Abuzar (Muhammad-Abuzar-code)
- Muhammad Rabee Umar (mrabeeumar)
This project was developed as a 2nd Semester Java Programming Project (SP26), demonstrating object-oriented design, data structures (priority queues, hash maps, binary trees), file I/O, and desktop GUI development in Java.