Recently I’ve encountered a rather strange behaviour related to Java Web Start.

If, in your .jnlp file you are referencing some signed jars, sometimes the verification fails miserably with the following stacktrace:

If you are 100% sure that your jars are correctly signed, check if your JRE setup have “Keep temporary files on my computer” option enabled. That solved the problem for me.

So if you are on Windows: Control Panel -> Java and then:

Hope it helps.

The process of converting an object into an associated sequence of bits, so that we can store it in a file, a memory buffer or share it across a network, with the sole purpose of later resurrecting it, is called Serialization Wikipedia offers a nice insight of what serialization is, so if you have time, please check this article . If this is the first time you hear about this concept you can check the official java documentation on this topic .

Recently I had to write a Serialization mechanism for a hobby application of mine . I had some very big objects (graphs represented as matrices) that had to be somehow stored as files for later usage . Serialization is not hard in Java, but the results are not always satisfactory . For example every graph object was using around 100M of my free and precious hdd space … and space is always an issue on my “workspace” partition (probably because I start so many “projects” and I never finish them) .

The work-around for this issue is relatively simple, instead of using a simple FileOutputStream / FileInputStream in conjunction with an ObjectOutputStream / ObjectInputStream we would better “wrap” the initial streams through a GZIPOutputStream / GZIPInputStream, and serialize the big objects as gzip files . The results are better than I expected, as the space consumption was reduced dramatically (3 or 4 times less space) . In my case the additional runtime for zipping / unzipping the objects before reading / writing them is not a problem, but note that because of the additional stream encapsulation (the GZIP streams), a time penalty appears .

To better demonstrate what I was saying I will start by designing a class that generates “very large objects” . The objects must support serialization, so our class implements java.io.Serializable . This is a “marker interface” and does not contain any methods that need to be implemented .

The VeryLargeObject class (not a recommended name for a class) encapsulates a bi-dimensional array of size [1 < < 12][1 << 12] . That means the array has 4096 * 4096 elements = 1 << 24 elements = 16777216 elements (I believe it consumes enough memory to prove the concept) . The second step is to build an util class that contains the functions necessary for serialization / de serialization . For comparing the two strategies, I had to write two pair of functions [saveObject(…), loadObject(…)] and [saveGZipObject(…), loadGZipObject(…)] . The big difference between the two pairs is that the second use additional Continue reading

As a mostly-newbie Haskell / fp programmer (one who only read http://learnyouahaskell.com/) I wanted to exercise my functional coding skills, by resolving non-helloworld programming challenges. So I’ve tried something classical:

Write a program that will convert an integer in the range of [1 .. 3,888,000] to the equivalent roman numeral:

The symbols are: (I = 1); (V = 5); (X = 10); (L = 50); (C = 100); (D = 500); (M = 1,000); (upperscore V = 5,000); (upperscore X = 10,000); (upperscore L = 50,000); (upperscore C = 100,000); (upperscore D = 500,000); (upperscore M = 1,000,000) .

Rules:

  • If a letter if followed by another with equal or lesser value, the two numbers are added (eg. XX = 20, LV = 55);
  • If a letter is followed by another with greater value, the first is subtracted from the second (eg. IV = 4, XC = 90);

Examples:

The numbers from [1..10]: III, III, IV, V, VI, VII, VIII, IX, X
Other numbers: CDLVI = 456 , MCDXLIV = 1444 , MMMI = 3001 , etc.

and now… The solution (one of them, probably far from the best)

The main idea was to divide my solution into small reusable blocks.

1. First I’ve written a function, figures, that transforms a given number into a (reverse) list of figures. For example, 1113 becomes [3,1,1,1], 1234 becomes [4,3,2,1] and so on…

2. Then I defined a list (of Strings), romans, containing all the roman numerals. The upperscored versions were coded using an underscore :), like (upperscore X) = _X = 10, 000 .

Continue reading