Category Archives: Java

Useful code snippets in the Java Programming language.

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 , , , , , | Leave a 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

How To Print The Alphabet in Java?

In Java, the primitive value of type char can be converted to the primitive int. An an integer within the range of a character can be converted to a char. For example, the ASCII character code for the character A is 65, for B is 66, etc. Because of a char value can be interchanged [...]

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