Refactoring, Renaming, and version management

I’m using the netbeans IDE to write my Java and overall I think it’s excellent. It’s a completely different experience to perl coding where my idea of version management is to save-as a different filename. If I want to rename something in Perl I do just that. With modules it’s a bit more involved but not that tricky.

I was writing a Java program to interface with a SQL server. This program morphed into something completely different so I decided it was time to rename it. Now what?

I discovered refactor->rename. Brilliant! rename to something else, job done. I re-compiled and ran it and got this:

NoClassDefFoundError:sql_test1/Main

Wha? sql_test1 was the old name, not the new name. The files had all been changed, what’s the deal? ok, google: java netbeans NoClassDefFoundError after refactor . Now sort through the results. No joy. I found that the project.properties file had the old name for main.class. Haha! Changed it to the new name. Then I got the same error except with the new name. What gives?

Eventually I found an article here where I found the answer: A) don’t use Main, your program to something else and B) The class must be capitalized! That’s what tripped me up, I had it in lower case. Once I renamed my class to be capitalized it all worked fine.

My conversion from Perl to Java

About 10 years ago I picked up a bit of Perl out of necessity. I’d had some basic programming instruction, literally basic, then a bit of pascal, then a semester of C in college so I had the vaguest of ideas what I was doing but that was all. So when I had to re-write a perl script that someone else had done it was all pretty new to me. Over the next 10 years I gradually built up my perl programming experience from basic scripts to automate network management to writing my own modules and large scripts of several thousand lines interacting with SQL databases and excel.

Am I a perl “expert”? No, but I am a decent hack and my coding skills have served me very well over the years. Perl is an amazingly flexible language, it’s been described as the duct tape of computing but I don’t think that does it justice. It’s more like the Legos of computing, you can do anything with it and there’s add-ons for everything imaginable. It may not be pretty but it works.

So why learn Java? To write mobile apps. Perl is very command line, it’s not meant to build interfaces.

I’m starting this blog thread to record my experiences trying to convert from Perl to Java as others may have similar problems.