Posts
51
Comments
20
Trackbacks
5
Tuesday, June 30, 2009
Street Racing

In my spare time, I really enjoy playing Street Racing on Facebook.  I actually like to put all of my “Extra Points” into max gas so I can level up faster.  What do you do?  Is there an “Easiest Way” to level up?  Click here to join my crew!

posted @ Tuesday, June 30, 2009 10:10 AM | Feedback (0)
Friday, June 19, 2009
Using Java Variables

When programming in Java, it is essential to understand the basics of storing and using information that is stored in variables.  In this post, we dig a little more into detail about using Java variables.  If you are just happening onto this post, please read the pre-cursor to this as we learned how and why to create Java variables.  You can find that post here: Java Variables.

Java allows you to store variables at different times during programming.  The first place you might store information into a variable is at the time you declare it.  Declaration happens when you are assigning a type to a name (i.e. int number;).  When you are assigning a value to a variable, you use the '=' equals sign with the assigned value coming after the name of the variable.  You can do this when initializing your variable, or you can do it anytime after you have declared your variable (assigned a type to a name, int number;).  Below are examples of how you can accomplish this.

Assigning value to a variable at initialization:

public class Variables
{
    // This method is where we will play
    public static void main(String[] args)
    {
        // TODO: Variables assigned at
        // initialization.
        int number = 2;
        double decimalNumber = 4.55;
    }
}

Assign a value to the variable after initialization:

public class Variables
{
    // This method is where we will play
    public static void main(String[] args)
    {
        // TODO: Variables assigned at
        // initialization.
        int number;
        number = 2;
        
        double decimalNumber;
        decimalNumber = 4.55;
    }
}

Note: You can not use a variable before it has been initialized to a type.  This will result in a compiler error.

When using variables in java, you can assign variables different values along the way.  In this post we have described and demonstrated assigning variables at initialization time as well as after initialization.

Technorati Tags: ,,,
posted @ Friday, June 19, 2009 11:28 PM | Feedback (0)
Java Variables

Java variables are essential when programming.  At the core of variables, is the ability to store information in a java program.  Variables can store many different types of information.  Some of the most basic types are integers (int), doubles or floating point (double), characters (char) and String (String).  After reading this post, you should have a very solid understanding of how to use variables in Java.

All java variables need at least two things to be created.  The type, which tells Java what kind of information you are storing and the name of the variable.  The name is how you would access this information later in the program.

To start off, lets create a basic java file that we will use to get a better understanding of variables.  If you haven't done so yet, please visit my posts on getting java set up to operate: Using Java with The Command Prompt and Our First Program.

Fire up notepad or Notepad++.  At this point, my screen shots will be coming from the latter, Notepad++.

Create a new text file in your editor and save it as Variables.java.  I place mine in the C:\Java directory.  The first thing we will do with our file is create the basic layout.

public class Variables
{
    // This method is where we will play
    public static void main(String[] args)
    {
        // TODO: Play with variables.
        
    }
}

Next we will start by creating an integer variable, used to hold an integer number for out program.  Let's name our integer number.

public class Variables
{
    // This method is where we will play
    public static void main(String[] args)
    {
        // TODO: Play with variables.
        int number;
    }
}

Here is a picture and explanation of what the different words mean.  Notice that our type represents the type of information being stored in this case, we are storing a whole number.  The name of the variable is how we will access our variable in the future.  We can change, print, read and compare our integer using the "number" reference (or name) later in our program.

6-19-2009 9-46-54 PM

Now let's create a number that stores a value that has a decimal.  This could be known as a floating point number or fraction.  At the end of our previous line, lets enter a new line and create a double. 

public class Variables
{
    // This method is where we will play
    public static void main(String args)
    {
        // TODO: Play with variables.
        int number;
        double decimalNumber;
    }
}

Notice that at this point we have two variables defined.  Now we must learn how to use these variables.

posted @ Friday, June 19, 2009 10:01 PM | Feedback (0)
Sunday, June 07, 2009
No More Childcare

My youngest, Garrett is graduating from preschool.  This has been an exciting thing and I certainly look forward to seeing him grow into Kindergarten next year.  What a rewarding experience, being a parent is.

Here is his graduation picture for those of you that read.

mommy-n-garrett

posted @ Sunday, June 07, 2009 6:52 PM | Feedback (1)
Saturday, May 30, 2009
Oh My! I Have Fallen In Love, Again!

Edit:  Our puppies new name is Corduroy (Thanks to Jessie for the suggestion).  He is officially named after the Teddy Bear in the hit kids book, Corduroy.

Before I get too far into this post, this is just a short and sweet (Oh, look what I have, nah nah nah boo boo) blog post.  We still haven't figured out a good name, so please try to help us name this one if you don't mind.  So this breed is a so called "Teddy Bear",  he should grow to 8-12 pounds, and he is the most adorable puppy I have seen in years.

When my son pointed at him and said  let's take this one home, I didn't realize the eye that he had for wonderful dogs.  This is a Bishon Fris and Shih Tzu mix (Male), better known as a "Teddy Bear" or a "Designer" Puppy/Dog.  Since we have gotten him, we have absolutely adored him; the only real major road block is naming him.  So help us out.

Naming:  I like Dexter, after the Showtime series.  My wife like every generic name in the book, I have conceded to maybe Bear.  There has to be other names.  Look at his picture and let me know what you think!  (He is about 1.3 pounds).  Gizmo is totally out of the question.

IMG_3860

Thanks in advance.

posted @ Saturday, May 30, 2009 10:57 PM | Feedback (3)
Monday, May 25, 2009
Java: Getting Started

There is one question that I get asked pretty normally, so I am going to address it here.  When new to Java, the one thing that everyone asks, whether it is to me or to themselves or someone else is... How do I get started with a program?  There is only one real way to answer this.  I use a tactic called "Hello World" or "Hey" or whatever  favorite term comes to mind.  This means that I start a web project by producing those words programmatically through Java in html.  Or when I am creating new AJAX functionality, I often send those words first, before I tie in any data or logic.

So, in this post, we are going to go back and see how we might create a basic command prompt Java application.  I will discuss in short why we do what we do as well.  Before you run this example, you need to make sure Java is installed properly.

1. Start -> Run -> type notepad, press enter.

5-25-2009 2-20-43 PM

2. The first class in the file must be public and also named exactly as the file is going to be named.  These are nuances that are absolutely imperative to understand, though the reasoning behind them aren't as much.  So we will start by typing:

public class HelloWorld
{

}

3. Click File -> Save, then choose a location.  To follow my examples for the command line, you should create a Java folder on your hard drive (i.e. C:\Java).  Once you have browsed to your location, name the file HelloWorld.java.  Click Save.

5-25-2009 2-30-20 PM

4. Open a command prompt.

5-25-2009 1-49-35 PM

5. Change directory to the location of your HelloWorld.java file.  I will type cd C:\Java.  I will then attempt to run my program by typing javac HelloWorld.java.  If everything goes well, you can browse to the location (C:\Java) and witness two files in your folder.  One is HelloWorld.java and HelloWorld.class, the javac command, produced your class file. (Note: My first error was because I failed to save the file in the previous step #3)

5-25-2009 2-37-23 PM

6. Now we need to add the required static main class so that the Java Compiler knows what to do when we request to run our file.  This is required because the compiler will try to invoke HelloWorld.main(args) programmatically to kick off our process (Note: args is the array of strings that you can pass in on the command prompt, more on that some other time just know that it is a required parameter of the main method).  I modify the file in notepad to include this method as follows.  After you have this text in notepad, you can save the file and run step 5 again to make sure all of your syntax is proper.  If you have errors you will have to resolve these to continue.  Notice the placement of the method inside of the braces for the class HelloWorld.  This is the basic organization, if you mess up your brackets it is very likely your program will not operate properly, so this is important.

public class HelloWorld
{

  public static void main(String[] args)
  {

  }

}

7. There is a method, of System.out that we can invoke to print a friendly message to our command prompt.  This is how we modify to achieve our first Java program and a good way to start off other programs in the future.

public class HelloWorld
{

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

}

8. Once again, carry out task 5 to make sure your program compiles.  After you have compiled your most recent version of this file, you can type java HelloWorld and you should see it respond by printing out Hello World to you below your call.

5-25-2009 2-50-08 PM

In this tutorial you learned how to start a Java program.  This is the way that I always start off, to make sure all of my initial wires are plugged in.  Of those of you that may find difficulty in this tutorial there are a few habits we need you to get used to as soon as possible.  Pay attention to case, that is where your capital letters are.  In Java and programming there are many ways to do it, but we generally use Camel Case.  This allows everyone to be on the same page and is a very good habit to get use to that.

Please leave comments with help for others, where you may have run into issues and such so that everyone can benefit here.

posted @ Monday, May 25, 2009 2:55 PM | Feedback (0)
Using Command Prompt with Java

There are several things that I like about using the command prompt with Java.  When beginning to program it can be much less cumbersome than using a integrated development environment (IDE) like Netbeans or Eclipse; where the errors are less descriptive as I will demonstrate here.

To start off, I need to download a Java Development Kit (JDK), and I usually like to use the latest.  In this case it would be Java 6 JDK (at the time of this writing it is update 13, i.e. JDK 6 Update 13).  You can also download the documentation from there as well.  To view the documentation  on the web, you can look here at Java docs.

After selecting my operating system and acknowledging my agreement to their terms, I downloaded and installed JDK 6.  For now I will not register my product, so, with Java installed, I am ready to set up my environment so I can use Java (This example is in Vista 32bit, x86).

1. Click your start button, and roll over Computer and right click.  Select Properties.

5-25-2009 10-41-22 AM

2. Click Advanced Settings

5-25-2009 10-47-10 AM 

3. Select Environment Variables

5-25-2009 10-51-49 AM

4. Find your Path Variable under System Variables, Click Edit.

5-25-2009 1-34-01 PM

5. At the end of the Variable Value, make sure there is a semi colon.  This is where we are going to put the path location of the bin folder of our Java SDK.

5-25-2009 1-37-31 PM

6. Browse to your install location for Java (default is: C:\Program Files\Java\jdk1.6.0_13\bin), making sure you are in the bin folder, click the down arrow in the browser bar.  This will produce the Path variable you need to append in the previous note. Copy the location and go back to your Edit System Variables window(described in 5, above).  (Note: XP Users will need to do the same thing in their ClassPath variable as well)

5-25-2009 1-39-29 PM

7. Make sure you put a semi-colon after your path (to minimize future errors).

5-25-2009 1-45-08 PM

8. Click Ok in Edit System Variables, Ok in Environment Variables, and Ok in System Properties.

9. To test my class path, I go to a command line prompt (Start->Run-> and type cmd, Press Enter).

5-25-2009 1-49-35 PM

10. From your command prompt, type javac test, and press enter.

11. An error like the one below means that it is installed properly.

5-25-2009 1-51-08 PM

 

In this series you learned how to install the Java SDK, Set your Path variable and we also learned how to run a quick test to see if Java has installed properly.  Please leave tips/comments/errors for others to see so that we can make this post a little more comprehensive.  Hope you enjoyed reading.

posted @ Monday, May 25, 2009 1:54 PM | Feedback (2)
Sunday, May 17, 2009
Life, Getting Back to Normal

While I was away this weekend one of my chairs (bosses) called me and asked me to take on "Extra" work for the next 6 weeks.  This was the same case 6 weeks ago and may be a big reason why I haven't been blogging a lot.  Please bear with me though, I plan on kicking it into high gear in about 6 weeks.  I have several awesome things I have done down the path of JQuery, ASP.NET MVC, Grails (Groovy / Rails), and more that I would love to share.  Also some of my newer series will be coming out as we roll in the next couple weeks (newer series: tips for less experienced programmers).

posted @ Sunday, May 17, 2009 3:33 PM | Feedback (0)
Tip for Traveling

The airlines must have lobbied for Airport security to tighten down.  When I went to travel last week, through the airport, with my wife and 2 children, we realized that traveling without checking bags is now much more difficult.  When we were going there it seemed to take us 10 minutes to get through security because your liquids can no longer be packed away and your shoes can't go in a bin.  Why does this matter?  (Note: Kids are 5 and 7).  Can you imagine keeping track of a laptop, 2 Nintendo DS', 8 shoes, belts, liquids (in their own container), etc all singularly as you move through security.  The easier solution is to just pay the 15 dollars and check ONE bag.  We did this on the way back and it was much easier.

posted @ Sunday, May 17, 2009 3:28 PM | Feedback (0)
Tuesday, April 28, 2009
Google App Engine Supports Java
I was perusing around earlier and noticed that Google's App Engine now supports the Java Language.  It said New! next to it,  so I figured, why not blog it.

Here is a link to the Google App Engine.

Read more at their app engine blog.

I certainly look forward at trying to leverage their hosting services at some point in the future.  I will also be considering Amazon's EC2, as well as Microsoft's Azure.  Most of my sites are in ASP.NET but wouldn't be entirely impossible to refactor at this point.  What would you do?
posted @ Tuesday, April 28, 2009 1:27 PM | Feedback (0)
News
My opinion matters to me! This is my opinion place. Thanks for coming by.