Category: java

  • Regular Expressions in Java

    I was wondering why the gnu.regexp package exists, when Java already includes libraries for it. One thing I can think of is the fact that they’ve been added only in 1.4. During searching around I found some surprising facts about the built-in regex libraries (the site goes up and and down, so here is the…

  • Calculating the intersection of two Java sets

    This is my simple stupid Java tip for the day: to nondestructively calculate the intersection of two Set’s (ie, retain both object), do the following: Set intersection = new HashSet(s1); intersection.retainAll(s2); Taken from Java Tutorials. Lessons learned: before implementing code which even vaguely seems that it should already exists, check with your favorite search engine.…

  • Enumerations in Java

    Starting to (professionally) program in Java, one of the things which bugged me were the constant declarations in classes which implemented struct-like idioms: class Foo { public static final int FOO_1 = 1; public static final int FOO_2 = 2; public static final String FOO_3 = “42”; … The code referencing this seems even more…

  • Sun bans Romania from downloading

    Confirmed from multiple locations with multiple ISPs: whenever I try to download something (JDKs) from Sun using a Romanian IP you get: Your download transaction cannot be approved. Contact Customer Service. I’ve tried downloading a SDN account (so that Sun knows that I don’t want the JDK with all the non-exportable crypto stuff) to no…

  • Using Eclipse with OpenJDK 6 on Ubuntu

    Update: There seems to be a simpler way to do this. Take a look at the second comment. Java 1.6 (also known as Java 6) is now open-source so I installed it on Ubuntu and tried to run Eclipse with it. Unfortunately it said that no compatible java vm was found while searching /usr/lib/j2sdk1.4-sun/bin/java. So…