Epnix.Com

A place to test and try things out

Browsing Posts tagged blackberry

Lessons in Java

No comments

I have a plan.. Ok maybe not so much of a plan as a lose set of possibilities. One of which is to make apps for the Blackberry.  The reasons are 2 fold.  One is to make any oddball app that I want, though I have to admit the Blackberry community is pretty good at covering that.  The other is to make some a little bit of money, if I can sell 100 copies of a app that people want at a $1 a piece, that’s still $100 bucks more then I started with.  Not to mention the fact that in most cases I probably want the app also.  It give me more programming experience, so I’ll be getting paid to learn. Finally anything that is a web technology is good for my current career choice.  Not a bad deal all the way around.

Of course there is a slight problem, part one of this many part problem is knowledge of the Java Programming language.  I’m a little lacking there.  So This is the beginning of Project file on learning Java.

What will be seen under this category and tags is my notes on learning the language and some of the pitfalls along the way.  I know they will be useful for me, but I also hope that they will be useful to anybody else that may be trying to learn the language at a future date.  I guess one more thing I should say is I’m not trying to teach the language here.  There are plenty of books out there and some websites that will do that.  Again, this is more my thoughts, notes, and “discoveries”

My posts and projects are a bit disjointed at the moment, I have this listed as Project 2 even though it will probably be posted before project one.  I will be bouncing around to give the brain a break on a particular topic, and even thought I started the server project a bit ago, Java is what I’m working on now.

What I’m using:

I personally learn best from various “teach yourself” books and the one I’m reading right now is called “Head First Java” Second Edition, by Kathy Sierra, and Bert Bates (ISBN 0596009208) (hmmm side note, I guess if I’m going to do that I should learn how to do a proper citation).  It’s a 2005 book, but I don’t see a 3rd edition at this time, and this one does seem to be well regarded, with good and recent reviews.  So I guess it’s a good place to start.

For Java, using JDK 6 update16, which btw this was the first sticking point in learning Java.  You can’t just go to Sun’s website and click on the java button.  That’s going to take you the version that you need to run apps.  To write programs you need the development tools. Personally there is to many choices at that link.  If all  your trying to do for now is learn java look for the block that’s labeled Java SE Development Kit (JDK).  Download that and install.  The Book recommends also downloading the documentation.  Which I did, but haven’t installed it yet.  After getting it installed I had to add to the windows Path statement where the JDK Bin files where.  When copying the path from windows explorer make sure to copy the path to the JDK, not the JRE that installs.  Yeah, Duh! I know, makes sense huh?  Well sometimes logic fails at 2am.. oops!

Today’s Notes:

Source file Contains one Class, Class Contains one or more Methods, One method contains a set of statements.

Basic “Hello World” Program:

class HelloWorldApp {
   public static void main (String[] args) {
      System.out.println(“Hello World!”);
   }
}

NOTE the “S” in String[] is capitalized. Along with System, but I had gotten that one right. (Book uses a different example)

Must have a “main” method in every app, but not in every class.  Apps can contain multiple Class files.

Syntax:

  • Statements end in Semicolon’s
  • Most white spaces don’t matter
  • Must declare type and name of variables (ie. int weight;)
  • Classes and methods must be defined with in curly braces { }
  • // Single Line Comments
  • /* Multiline comments
        are like this with the Asterisk slashes */

while (condition) {
   statement;
}

for (initialization; termination; increment) {
    Statement;
}

One thing I can’t seem to remember the order of creation.

  1. write / Save the .java file
  2. Comple .java file : javac appfile.java This makes the .class file
  3. Run the .class file: java appfile.

I have a bit of a laundry list of things I want to do this weekend, but for some reason I can foresee only a small hand-full getting done. Why? well it’s not ally how long it’s going to take to complete each task, as individually they shouldn’t take that long (well except for overhauls for 2 websites which will probably take a whole weekend each, but lets forget about those for now).  The problem is that they mostly involve my favored tool and toy, my computer.  You know, the piece of equipment that is suppose to make our lives easier, and allow us to get things done faster.  Instead it seems to promote a form of block where time and space comes to a complete stand still immediately around you, while the rest of the world plods on.  This is demonstrated as one looks at the clock and finds they have been working on that one quick thing for roughly 5 hours. 

I’ve been trying to pick apart this phenomenon and it this last case I came up with this sequence of events.

I got a blackberry for Christmas, a week later it turned into a not so wonderful paper weight.  Verizon did replace it, however, I never backed up my address bookthat I had copied over from my old phone, nor had I synced it with outlook.  I did have a printed list, thank you print copies, and after getting home from work (and taking a bit of a nap) I decided to re-add the names.  This should have only taken a hour tops, as I really don’t have a lot of people in my (accordingto outlook I have 25 names in my address book)  So REALLY this shouldn’t take that long.  then all I would have to do is sync up the phone to outlook and done … Right?  Well I get to one person that is also here on Facebook, and I think, hay, why don’t I get their picture off their facebook profile to use as their caller picture.  Of course when I log in, I see that I’ve been “Kidnapped”.  For those that don’t know, Kidnap is a Facebook program that seems to be tied in with the travel channel, and is now one of the few apps I’ll use.  What happens is one of your friends kidnaps you to their evil lair using one of a verity of possible methods (the more you play, the more points you get, the more points you get the more methods you get).  To escape you have to answer a trivia question about the city the kidnappers lair is.  Which is why I like it, because I’m leaning nifty little facts about places around the globe.  See! I don’t totally hate being educated :)   Anyhow, as I said, seeing as I was kidnapped I “HAD to” escape.  Now, I don’t know if it’s “cheating” or not.  Personally I think it’s the intention of the app to get you to hit the “cheat-sheet” button cause from that point the Travel channel can now start advertising to you. which is why I do it all the time, hmmm someone let me know if I’m wrong.  Anyhow so I hit the cheat-sheet and start researching the answer, finding that, and answering the question leads me to go off and kidnap a few people also.  You know I get points for escaping, so I feel obligated to give others the opportunity to get the same.

With that done, I’m back to the task of getting the picture, however I also then notice status updates, and of course the fact I haven’t updated mine in 2 days.  So first things first comment on how I have a lot to accomplish, but feel like I’m getting no where (Yes Amy, thinks for pointing out that part of the problem was I was on facebook kidnapping people, I know, I know) , then comment on other peoples statuses… then comment on other comments and so on.  Then check the groups.  Oh look a few posts on the blackberry group.  I go to check them out and respond to one.  In the process though I forget the same of the group within Research In Motion(RIM)  that creates the toolkit to make themes on the blackberry (Plazmic).  Now I want to post this response cause I know the answer and like to be helpful, contrary to popular belief some people may have.  Course this means I need to open another tab in the browser and go to the blackberry sites forums and find the post that has the name of the organization that I’m looking for.

Logging in over at blackberry support forums, I see a few posts that interest me, again one question that I know the answer to, and one that I want to know the answer to.  Time continues to tick away as I read though comment after comment on the one.  The good news is I really did know the complete answer to the other one so it, for a change, only took a few seconds to answer.  Then I get back to the process of hunting down the name of the group that makes the theme toolkit.  I do finally find it (it was on page 3 all the posts) and slap my forehead for forgetting.  OF course at this point a more focused person would go back to facebook and answer the question to move back on task.  Ok more the likely a more focused person wouldn’t have been sidetracked to begin with, but I lets forget about that as I didn’t do either.

No instead I think I should check to see if in the past 2 days Plazmic released the tool kit.  So I open another tab in IE and head over to plazmics forms.  First thing I see is that, No, the toolkit is not yet ready (quick rant, as posted in other places… COME ON PLAZMIC.  The Strom has been out for 2 months now, and the Curve 8900 has started rolling out, you should know this as your a division of RIM, what’s taking so long for the CDK????  Ok rant done) Anyhow, I had to add my thoughts to a growing post of people waiting for the toolkit to be released. 

Now with information found, and verified, I can close the Plazmic tab, close the Blackberry tab… ok  Maybe not close that one, cause I’ll just want to go back later anyhow. Tab over to Facebook, answer the post about theme’s now head back to my main page to get that picture… oh look, more updates…….

After finally going though the updates and the returned kidnapper’s I finallyget the picture, and get back into outlook… Total round trip time…… about a hour or so.  With the picture added, I move on to the next address… hay look, they’re in facebook also…… Rinse and repeat.

So all in all it only took me a few hours to add 25 names to my address book, and I wonder why I never seem to get anything done.  The good news about all this.  It gave me something to blog about… look 2 checkmarks off my list for tonight. and it’s only 11pm *sigh*

Edit: Oh and I forgot, i wanted to post this in the middle of the blog, but it didn’t seem right.  I was listening to the Rush CD – Rush in Rio while writing this (and well getting other things done.  Neal Pert is a beast on the drums, ever watch him?  favored songs on the album, ok I like them all but Driven, Resist, and O Baterista (Neals drum solo) really stick out.