Closed artknight closed 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!"
@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$
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!
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