RARoScope - Java Library for Scanning RAR Archives

17th Mar 2008

Ever faced the challenge of having to be able to scan RAR archives using Java? Wished the API was as simple and easy to use as the ones provided for ZIP and JAR handling in Java? Don't want the hassles of including expensive native code into your Java application?

RARoScope is here to solve all these woes. The following lines are all you've to write to list out all the entries of a RAR file, say, "D:/Data.rar".

    // Construct the RARFile object using the file path
    RARFile file = new RARFile("D:/Data.rar");
    // Get the handle to the Enumeration
    Enumeration<RAREntry> entries = file.entries();
    // Iterate and print
    while (entries.hasMoreElements())
        RAREntry entry = entries.nextElement();

Listing 1: RARoScope API being used to list all the entries of a RAR file.

Impressed? I sure was thrilled when I first wrote the library! Go ahead, download RARoScope and start using it in your applications right now.

What RARoScope can do?

Exposing a simple API, RARoScope packs the following rich features.

  • Enhanced checking for true RAR archives.

    RARoScope ensures false RAR archives such as files with just a ".rar" extension do not interrupt further processing by reading and verifying the RAR marker header block and throwing exceptions where appropriate.
  • A rich RAREntry class.

    RARoScope reads almost all the information available in a RAR archive and loads them into the RAREntry instances. Following are the file metadata retrieved.

    1. Full file name including the path
    2. Date and Time the file was modified/created
    3. Compressed file size
    4. Uncompressed file size
    5. The CRC checksum for the file
    6. Whether a file is a directory
    7. The operating system on which the file was added to the archive
    8. The compression method used
    9. The RAR version required to decompress and retrieve the file
  • Optimized for performance.

    RARoScope has been designed to make efficient use of the underlying byte buffer so that very few I/O reads happen in each cycle. An effect of this is improved performance with very small cycle iteration times.

What RARoScope can't do?

However, because of various factors, RARoScope does have its limitations and can't do the following.

  • Creating RAR archives.

    Because of the proprietary nature of the RAR archive format, RARoScope can't be used to create RAR
  • Reading file contents/decompressing.

    Since RARoScope has been poised as more of a "RAR scanning library" rather than a "RAR decompressor" for Java, it can't do the decompressing part. However, this is open to change in the near future. Depending on the response I get, I might implement a decompressing logic.
  • Reading RAR entries with comments.

    RARoScope doesn't support reading comments and entries with comments as of now.
  • Multi-volume RAR archives.

    RARoScope doesn't support reading multi-volume archives yet.
Technorati Profile

What others say

Raghavan 19th March 2008
Hey buddy,

its a good piece of work. Appreciate it! It works fine with my happy-path scenario testing as such.

Don't know this comment atleast passes through or not? Let me see my luck. If not, i think i will have to send the comments through Email :)

Keep going.
Best Wishes..

Raghavan alias Saravanan M.

Thomas 16th May 2008
Nice work. Would be nice if it could also uncompress. I tried the java unrar project. That one can also uncompress but has problems with my archives :-( So I will come back in some month. Maybe you have improved it.

Cassius 20th May 2008
Not bad, but can anyone point me to a rar library that can do multivolume extraction?

Cy-33 1st July 2008
Nice project! Could you improve it to decompress archives with password?

Laurent Muller 23rd July 2008

Great program !!! If You can also decompress entries, this will be perfect !

Thank You

Laurent Muller 23rd July 2008
Hello, Take a look at the RAR format on:


Best regard


Rob 24th October 2008
I was using a library created by Chillkat soft to decompress using java. Their's is okay for decompressing but it requires importing a dll so yours would be a lot better!!!

However, yours is already better for the transversing. Theirs offers similar functions but returns incorrect sizes for large files. I contacted them about it and they said it's impossible to fix, clearly thats not true!

Adarsh R 24th October 2008
Thanks everybody for the support and encouragement. Now I truly sense how important it is to be able to decompress archives using my library. I shall not disappoint you. :-)

wahith 25th March 2009
After downloading where I need to save this .Any other things to do after downloading

Adarsh R 25th March 2009
As I said, this is a Java library. You need to put the JAR in your classpath and write a program to use it.

Qunhuan Mei 8th May 2009
Great stuff! Decompress does seem to be more useful. Also found http://sourceforge.net/docman/?group_id=198859\. It looks very big (have not studied it yet) - may be you could join their effort if you share the same objective.

Really appreciated and best regards,

Norberto 12th June 2009
For when will there be a decompressing functionality available? This is nice but quite useless without de/compression

Adarsh R 13th June 2009
Norberto, I completely second that. I understand the importance of decompression, but wish I had more than 24 hours in a day!

Let me know what you think

Thank you. Please note that comments are moderated and will take some time to show up here.
Name (required)
Email (required but never published)
How much is two + three? (kill spam)
Your Comments (2000 characters max) Characters left: 2000