Thursday, March 31, 2011

NetBeans variable naming

Just a quick note since I'll forget later how I blew an hour of my time with NetBeans.

I received an error in the Generated Code section. This is annoying because you can't edit that section. but it is also good considering the time saved with GUI building. Anyway, the error was:

cannot find symbol
symbol: variable jdesktop
location: class java.lang.String
javax.swing.ActionMap actionMap = org.jdesktop.application.Application...blah...blah...blah

Looking at the generated code, the "jdesktop" had the red error squiggle underneath it. Usually with a "cannot find symbol" error, you take a look at your libraries and classpath and make sure they are OK. I hadn't touched them and the code was building just fine an hour prior.

Well, it turns out I had created a data member: "String org". "org" is a common abbreviation for "origin" when talking about flights (which is what this code deals with). Well, there is clearly no "jdesktop" member or method in the String class, hence this error. Ugh. That will teach me to abbreviate my java data member names. I changed it to "origin" and the IDE was happy again.

I guess you'd have the same problem if you had a data member called "com" and were calling some com.* class in a static way. Overall an unproductive hour, but an important lesson as well. I'll call it a wash.