Day 1

In previous experience working with languages, frameworks, toolkits, etc, I’ve always thought it much more important to learn the language first, and any supplements (API, framework, library, whatever) after I had a good grasp of the core language. If someone with no web experience asked me how to build an app with Sencha Touch or Ext.js – I’d tell them to ignore both until they had a good handle on JavaScript itself. So, taking my own advice, I decided to try to tackle Java first, and then move to the Android specific stuff.

To start, I googled various forms of “getting started with Java”, and learned that they’ve got a well-established IDE called Eclipse, and that I’d need the “JDK” (basically “SDK” but with “J” for “Java”).

I downloaded and installed both with no problem. I hadn’t planned it, but I installed the JDK first, which I think might have mattered – I’d guess that you should follow that order (JDK, then Eclipse).

So – another google on variations of “Java tutorial sample beginner introductory” led me to these tutorials: (but no eclipse) (yes, 2004)

The syntax is a little different, but it looked pretty straightforward. I decided to give it a shot. I created a new Class with just one public static method and successfully printed “hello world” to the console – I’m on my way!

Apparently “main” is kind of like a constructor – it always gets called.

Feeling like a pro already, I drew on my illustrious AS3 background and decided to get a little fancy – I created a package and a class within that package, with one method… “say”

… and in my “document class”, created and instance and invoked the “say” method…

… seems straightforward enough, right? Nope. Apparently Java doesn’t count single quotes as string delimiters. The IDE (which is extremely helpful at this stage) was telling me that this line:

contained an “invalid character constant’… Without really understanding why, something told me to use double quotes – lo-and-behold, it worked.

So – back in the saddle – I returned to “document class” (I have no idea what to call the main class that runs everything yet), and “tidied up” – I figured I was never going to pass arguments to “main”, so removed the “String[] args” parameter from the signature.


java.lang.NoSuchMethodError: main Exception in thread "main"


So I figured I needed to add a “main” method to my Talker – still no love.

A quick google showed me that all the “main” methods had that same signature “String[] args” – so I added that to both the doc class and the Talker, tried again…


Feeling cocky, returned to Talker and removed the “main” from there…

still works…

Do I need a constructor if nothing’s happening (I don’t in AS3 or PHP)…?

removed constructor from Talker…

still works!

So – apparently “main” is required in the document class, and MUST accept a string argument (dunno why yet…)

Figuring I’d pushed my luck as far as it’d go, I decided to wrap up for the night. Let’s see if we can’t understand a little more of what’s going on here, tomorrow.

1. I’m very glad I came at this with a ton of experience with AS3, even more so than the ton of experience I have with PHP. Initial impression is that this is VERY similar to AS3 – packages, imports, etc – PHP’s version of OOP is great, but this stuff looks a lot more like AS3.

2. The IDE rocks. For years, I proudly coded everything in Notepad… Recently, I’ve sold-out a little and used tools like Notepad++ or EditPad Pro, or FlashDevelop for AS… Except for FD, they have syntax highlight and regexp replace, but no code-hints or -completion, and very little error management, which is fine – I’ve been writing those languages so long I honestly seldom need them. But for something new like Java, I’m sure I’d still be pounding my face against the monitor wondering why single quotes didn’t work, or why including the component name in the package declaration fails…

3. The lack of “output” is disconcerting. Sure, we have the console, but no visual feedback as to what’s going on. The bottom line for any application is what the user sees and interacts with, and I think I need to figure out how to make “something” pretty soon…