Emma – A Free Java Code Coverage Tool

Writing by on Sunday, 22 of June , 2008 at 5:03 pm

EMMA is an open-source toolkit for measuring and reporting Java code coverage. Tutorial Coming Soon…

Leave a comment

Category: Java

Copy To Clipboard Doesn’t work in Java

Writing by on Friday, 30 of May , 2008 at 10:59 am

We recently migrated from Java 4 to Java 6 and found out that Copy To Clipboard from JTable, JTextBox etc. just didn’t work.

String selection = “Clip This”;
StringSelection data = new StringSelection(selection);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(data, data);

Then I happened to notice that there was an exception on startup and it couldn’t find flavormap.properties.

FileNotFoundException:C:\Program%20Files\Java\jre1.6.0_06\lib\flavormap.properties

It occurred to me at that point that the there was a SPACE in the location “Program Files” and God Knows why thats not handled correctly. So I simply uninstalled Java 6 from its Default Location and reinstalled it in C:\jdk1.6.0_6 and that did it for me.


Change Default Install Location
I did a lot of searching for solutions, but looks like nobody else ran into this problem. Hey, fixing these type of issues is what we developers get paid for, right? But Microsoft, Sun – PLEASE – Don’t point fingers at each other. Just handle these issues.

Leave a comment

Category: Java

SQL Server First, Last Aggregate Functions

Writing by on Tuesday, 20 of May , 2008 at 4:01 pm

Are you getting a SQL Server error saying that FIRST or LAST are not recognized or unsupported?

Error:’FIRST’ is not a recognized built-in function name. Number:195 Severity:15 State:10

Thats because they’re not.

SELECT LotFk, FIRST(RedemptionPeriodDate) as RedemptionPeriodDate -- ERROR 
FROM InvRegister
GROUP BY LotFk

Workaround is to use MIN or MAX

SELECT LotFk, MIN(RedemptionPeriodDate) as RedemptionPeriodDate -- VALID
FROM InvRegister
GROUP BY LotFk

Leave a comment

Category: SQL DB

Date Truncation in SQL Server

Writing by on Tuesday, 25 of March , 2008 at 11:47 am

Need to trunc dates in SQL Server? Follow the examples below.

SELECT DATEADD(HOUR, DATEDIFF(HOUR, 0, GETDATE()), 0)   -- 2008-03-25 10:00:00.000
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)     -- 2008-03-25 00:00:00.000
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) -- 2008-03-01 00:00:00.000
SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)   -- 2008-01-01 00:00:00.000

Leave a comment

Category: SQL DB

SQL Server Quick Workaround To Declare Arrays

Writing by on Tuesday, 18 of March , 2008 at 5:11 pm

Need a quick workaround to declaring arrays in SQL Server?

-- Trying to accomplish something like this?
int[] @list = {1864, 1966} -- INCORRECT SQL 
SELECT * FROM Employees
WHERE id IN @list

Here’s a workaround

DECLARE @list TABLE (id int)          -- create an int[] "array"
INSERT @list VALUES (1864)            -- hardcode values
INSERT @list VALUES (1966)            -- hardcode values
SELECT * FROM Employees               -- my query
WHERE id IN (SELECT id FROM @list)    -- use the int[] array

Leave a comment

Category: SQL DB

Find Bugs

Writing by on Friday, 22 of February , 2008 at 5:03 pm

Find Bugs is an open source tool that looks at your source code (actually class files) and compares it with a bunch of “buggy patterns” and report potential problems. This is called a “static analysis” tool which means it analyzes your program without actually running it.

IBM has a nice tutorial Find Bugs Part 1 – Improve the quality of your code

Leave a comment

Category: Java

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.