Friday, September 10, 2010

Ok so it has been a week.

No I haven't given up on my quest to learn how to program Java and inevitably learn to program for the android devices out there. What has happened though was a bunch of stuff in the real world like job interviews and everything, but more importantly i picked up a new Java programming book. This book is far more friendly to new developers than the previous, it has examples that compile, and it teaches you the basic. Why I went this route was to be able to learn the basics with one book and then learn the advanced style and information once done with that or even during the reading of the new book.

I almost hate myself for saying this, but I decided to give Java  For Dummies, 4th Edition. I've often thought myself better than these books but to be honest it doesn't hurt to knock myself down a peg to learn something new or different and as such here I am reading this book.

So yeah, here I am with a new book in hand and still I read both the other books to learn things. The other Java book is still quite resourceful and I've read through all of chapter 4 and parts of chapter 5 so its still being used but only for informational purposes rather than educational.

Friday, September 3, 2010

Apology is necessary

Ok, so I did intend to continue my endeavor into Java and Android more thoroughly this week but with Ubuntu 10.10 beta being released yesterday I've spent most of my afternoon, night, and even this morning trying to get it set up on my netbook and it has proved to be more than I'd like to handle. Not because it's a bad product but rather because the wireless configuration in my netbook isn't a properly supported device.

Only a minor setback, hopefully this weekend and next week will prove more fruitful!

Thursday, September 2, 2010

And so it begins again.

So there I was, broken and defeated by a rather disapointing chapter of what I thought would be my tutorial into a life of programming. I sat there pondering my path forward, then there was a glimmer of light at the end of an otherwise dreary tunnel. Walking forward I get closer to the light.

On the other side of the tunnel there was nothing to come out of my mouth other than one thing I had on my mind. What came out of my mouth was nothing but mind blowing to myself. This is what came out:


Now I know, this isn't a huge step forward, but it is a step in the right direction I feel. Not the most complex app out there but it was deployed to my Droid and it works perfectly fine which made me happy. This new book is quite a bit more trying than the previous book, it assumes you know a lot about Java (which as you might recall from my last post, I only know basics).  If its a struggle I have to face, then I shall.

Heres to hoping more apps will be pushed from my keyboard into my Droid and onto other users in this world.

Wednesday, September 1, 2010

Well that was quick.

So, to be fair, the book is a great book. To be even more fair, the book was a great book. Long story short, chapter three and beyond hold no real examples of code that you can compile. Why do I not like this style of learning? Well for one, its hard for me to figure out how things work without being taught an example and then how to use it in an actual program. All the book decides to teach you is little snippets of code and how to make use of certain classes, but not necessarily how to make use of certain classes in programs. I know this isn't a major problem and I will still continue to read the book however from now until I get bored of it I will be reading Pro Android 2 to learn how to program on my Android device.

If you fear for my sake of learning that I will never truly learn the art of Java programming, fear not! This is only a minor turn on the path of success that I feel is necessary, I'm still going to finish reading the book I started with but in stead of using it as a learning mechanism I will be using it as a reference to how to do certain things.

Unfortunately, with this discovery of lack of usable code, I will also unfortunately not be providing any examples of coding that it had me produce since they are all a variation on "Hello World" there wouldn't be much sense to it. I would have to heavily modify what little i had done to not infringe on the authors efforts on that chapter alone. So for that, I must say i'm sorry and I do hope to have something up for examples throughout my learning of Android and Java in general.

My apologies to all.

Tuesday, August 31, 2010

Chapter two. Completed!

Alright, so I just finished chapter two and if i do say so myself, the examples brought forth in this chapter were amazing and complex for a new to Java programmer. It was a fun experience, to give you folks an idea of what i mean the first program you are taught to make can be from anywhere from 10 to 20 lines of code. The author then proceeds to have you make changes to that code and each consecutive example gets quite larger, the second example is 40 lines of code. The third example is 67 lines and with the final example being 80 lines.

To those inexperienced in trying to learn a language, 20 to 80 lines of code seems a bit extreme on how to make a Hello World application.  For example this is the standard Hello World application that most tutorials takes you through:



class HelloWorld


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

Now you might wonder why I like the book making me take the longer route to learning this and I'll tell you. I like the book because it has me programming in a window rather than for a console style application (in Windows, your command prompt. in Linux this would be referred to as a Terminal typically) which I find fantastic. Who wants to learn how to program for an what seems an aging system other than for using scripts in Linux and very specific applications in Windows.

For this, i give the book another thumbs up, even the Hello World application(s) were a challenge and i respect that!

On a side note, I'd like to inform folks Ii have found a book to learn Android development once i'm through with this Java book or even most of the way done with it. I'll be reading this book to learn about Android:

Pro Android 2

And now come the inevitable "But Jimbo, why are you picking a PRO book? Aren't you LEARNING Java?". Well, you'd be right in that question but based on reviews on the beginner books and all the other style books, it seems to me that this book covers both the basic and advanced style of approaches and examples. So, I'm getting the Pro book so i can not only learn the basics but learn how to make them into more advanced style apps for my lovely Droid.

I'll hopefully get the Java files uploaded for others to see the code work that this book has you do. Unfortunately due to the preface of the book I may have to modify the code quite drastically or make my own personal changes to it to respect the author's work since it truly is a great book. Since i'll be having to tweak things in the code it may take a bit longer than i want.

Onto chapter three!

Monday, August 30, 2010

How to set up Eclipse IDE for Ubuntu Linux

Being an avid user of Ubuntu Linux, and various flavors of Linux as a whole, I have to give at least a basic how to on getting the Eclipse Java IDE to install and run for other users of Ubuntu.

First and foremost anyone looking to use Eclipse to make a Java program is going to want to ensure that you have the Java SDK installed. As such, you're going to want to follow this tutorial:


Now, I'm sure you guys are thinking "Well, Jimbo, why didn't you just tell us how to do all that?!" and to be honest theres no reason I couldn't. I guess a little part of me just wanted to make sure I didn't mess that up for you folks. Following that guide will ensure you get the java SDK installed properly and hopefully working.

Here's where I come in handy. It is late here and I didn't plan to do this, but it came to me as an idea when i realized I wasn't sure how to set up the Java project settings in Eclipse when i tried to use Eclipse to program while i was reading the book.

Theres an easy method and a more time consuming method out there, first the easy method.

Open up a terminal (Applications > Accessories > Terminal )
Once in the terminal type the following:


sudo apt-get install eclipse
Hopefully this works for you, it didn't for me ;).

With all the troubles I went through I ended up at a site I've visited quite frequently known as Ubuntu Community Help . This page describes how to do a number of things but the one i had to follow was the User Installation section. 

Once you get it installed and want to proceed with creating a Java project in there to get some programming on then go ahead and keep reading. Open up Eclipse first, there will be a dialog box about a default workspace, go ahead and leave it or change it since it doesn't much matter. the workspace controls where all the files and projects get stored on your hard drive.

While in Eclipse go ahead and click "File > New > Java Project" . Once you press Java Project you'll see a window like this:



Theres a few options here that matter, quite a bit actually. The first thing you'll notice is Project Name: and thats the big one, name it whatever you would like, it's going to refer only to the project and not the class file. Below that you'll see the content section radio buttons, just select the top one "Create new project in workspace". Then you'll see the JRE section below that, this is the important one, go ahead and select the top one and in the drop down button select yourself "JavaSE-1.6" if you don't have it in the list let me know, I'll see if I can't help. Theres two more sections left, Project layout and Working sets. On project layout go ahead and select the second option of creating seperate folders. Lastly the Working sets leave that blank for now. Press Finish.

Once you press finish hopefully you'll be brought back to the main Eclipse window with a little bit of new stuff on the left hand side. Under the Package Explorer \ Hierarchy section you should now be seeing your project name.Double click on it and you'll see something along the lines of this:



With "src" being selected, go ahead and right click it or go to File. In the menu select "New > Class". once you've done that you'll see a new popup similar to this:




Leave everything pretty much default. For a simple rundown, the Source folder should be your project name followed by "/src" so mine for example is "Enter_Name_Here/src". Package can be left blank, which is default. I'm not sure what Enclosing type is, so google that if possible. Name will be the only thing to change here. The name of this class will be well, the name of your class you'll be programming. So if this is your first program or whatever enter "HelloJava" in that box. Make sure the Modifiers radio button is selected to public and the rest should be left to default. Go ahead and press Finish now.

You'll be taken back to your main window of Eclipse again. If you did everything right you should be presented with a screen with a very similar look to this:




Hopefully, from there you'll know where to go, the center box is your main code section and where you'll be doing most of the work. 

I hope this helped someone, since for some reason my brain wasn't working when I tried to do this very thing. Obviously I figured it out and am now in business making Java things.

Good luck!

Just a minor note.

I just wanted to let folks know that if they are curious, I will be posting up my code in the form of zip files with the Java code inside. This isn't really for any major reason other than i want to share what I've learned and potentially help others in their quest to learn Java. I'd also like to have people respond with suggestions and everything on how I've wrote my program if it's an outdated style of programming or if there is any quicker methods to writing something I'd love to hear from you individuals out there.

There isn't any date yet where I'll start posting, but maybe tomorrow, maybe Wednesday, who knows. If someone knows of a way to post the code on a site without zipping it up let me know as well, I'm sure there are sites out there but I'm not currently concerned really with that but rather learning Java!