Category Archives: Java

Useful code snippets in the Java Programming language.

Keep Code Statements Simple

I don’t count my progress by the line of codes but at the same time I don’t take pride by over engineering a solution. Writing code is like writing for a publication, you have to know at what reading level you are writing for. That said, the one type of code statement that gets under [...]

Also posted in Programming, Rant, TechKnow | Tagged , , , , , | 2 Comments

Find the Current Working Directory in Java

There are times when you don’t have full control of the location where your Java application runs from. This could happen because the application is installed in a location other than the one recommended by the installer, or because it ran from the IDE, or some other reason. For whatever reason, if you need to [...]

Posted in Java | Tagged , , , , | Leave a comment

Remove Multiple Null Values From A List in Java

I’ve had situations where I’ve needed a list of foreign keys (fks) that I get from a result set and from that list make additional queries. Sometimes for whatever reason there are null values in the list and I have to remove them. You might had a similar problem where you needed to remove multiple [...]

Also posted in Programming | Tagged , , , , , | 1 Comment

Launch Default Web Browser in Java

For the longest time I’ve used the BrowserLauncher library to open the default web browser to a specified web page from Java. BrowserLauncher is simple to use, just import edu.stanford.ejalbert.BrowserLauncher and call openURL method with the desired website URL. Since Java 1.6, the JDK has introduced the java.awt.Desktop class to do the same so you [...]

Also posted in Programming | Tagged , , , , , | 1 Comment

Where To Download Previous Versions of Java

Earlier this week I received the following Skype message from a co-worker. [10:10:15 AM] i can not find an where to download official Java 6 update 23 [10:10:21 AM] mostly its from third party sites I can’t even begin to state how many things I find wrong from the above message. Normally I would just [...]

Also posted in TechKnow | Tagged , , , | Leave a comment

Can You Spot the Infinite Loop?

Can you spot the infinite loop in the following snippet of code? The above code caused a critical bug in a application I was working on. At first sight, the code looks okay, especially since it compiles. It’s a do-while loop with a condition that seems that it would break when the variable i is [...]

Also posted in Programming, TechKnow | Tagged , , , , , | Leave a comment