olle / lz77-kit

Some LZ77 compression utilities for the handy hands-on developer in search for a few less bytes of I/O.
http://www.studiomediatech.com/projects/lz77-kit
MIT License
65 stars 23 forks source link

Main method not found #4

Closed artknight closed 7 years ago

artknight commented 7 years ago

Hi, I get this error when I try to run it

Error: Main method not found in class LZ77, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

olle commented 7 years ago

Hi, there's currently no main-wrapper or executable (or jar for that matteR), just the source code that you can use on a copy-paste-basis. You will have to write a Java main-wrapper yourself and call the LZ77-class from there.

There are a couple of nice static methods you may call directly:

String compressed = LZ77.compressStr("Hello World!");
String original = LZ77.decompressStr(compressed);
System.out.println(original); // "Hello World!"
artknight commented 6 years ago

@olle I added this method

public static void main(String [] args) {
        System.out.println("LZ77 compression/decompression started...");
        LZ77 lz = new LZ77();
        System.out.println(lz.compress("hello world!",null));
    }

but the output is the original string, no compression happened.

iMac-2:jars johndoe$ java -cp LZ77.jar LZ77
LZ77 compression/decompression started...
hello world!
iMac-2:jars johndoe$ 
olle commented 6 years ago

Hi @artknight, I've added a main-method to the LZ77.java file. And there are some new tests which may show the way.

You are getting the correct results, the algorithm just isn't compressing anything since it's not able to find a worthwhile series of characters to compress. In other words, only longer strings with lots of repeated chars will be compressed.

This perhaps a good time to read through the code, and see how the algorithm works, and how it's influenced by the window-parameters.

I hope this cleared up some things.

Thanks for getting in touch!