Tuesday, February 15, 2011

Java : Baby Steps

As we indicated yesterday, we plan to post a series of pieces about Java. We don't intend (or expect) to teach anybody basic programming concepts - like for loops - there are plenty of better places to learn that stuff. What we'll focus on is the practical difficulties for a newbie getting started with Java.

The first big hurdle we encountered was in installing the language - almost a show-stopper. We decided to install the Java Development Kit (JDK) and the Netbeans Integrated Development Environment (IDE) at the same time, and downloaded the  <JDK 6 Update 23 with NetBeans 6.9.1>  package from <oracle.com>.

We started up the installer and then sloped away for a coffee. When we got back, there was a shiny new "Netbeans" icon on our desktop. After a precautionary reboot, we clicked on Netbeans and received a couple of error messages: "The JDK is missing" and "Cannot locate java installation in specified jdkhome : C:\Program Files\Java\jdk1.6.0_23. Do you want to try to use the default version?" We then wasted an hour or two tinkering with environment variables and the Netbeans configuration file ("netbeans.conf") before realizing that the first error message meant exactly what it said - the JDK was missing: it hadn't installed at all.

So, we ran the installer again, and this time the JDK installed.
WTF?! The first of many Half-Assed Excellence awards for Sun/Oracle.


We then followed the instruction in step 4 on the oracle.com page linked <here> to set our PATH environment variable. This is so you can compile a program by typing "javac Sucio.java" in a DOS box, rather than having to type "C:\Program Files\Java\jdk1.6.0_23\bin\javac Sucio.java" - which would get old very fast (unless you're Mavis Beacon).

Having gone to the trouble of downloading and installing Netbeans, we decided not to use it just yet. IDEs are a great tool for experienced programmers to crank out code quickly, but they can get in the way of learning about a language. (And we're too lazy to RTFM.)

So, for now, we're going to edit our code using Programmer's Notepad - a nice little editor that knows about Java syntax (and a lot of others) - which can be downloaded free <here>.

Next time, we'll run through compiling a traditional "Hello World" program:

class HelloWorldApp {
    public static void main(String[] args) {
      System.out.println("Viva Sucio!");
    }
}

(The code sample above was posted using google-code-prettify following the instructions posted <here>.)

23 comments:

  1. Java is a giant pain in the ass sometimes.

    ReplyDelete
  2. so confus... where is step one? >:3

    ReplyDelete
  3. Hello!

    thanks so much for your comment :)!

    i love the name....baby steps hahaha so cute :))

    Wish you a great time :)

    with love
    Mariza
    http://mar-iza.blogspot.com

    ReplyDelete
  4. I haven't got a clue what's going on. This does not mean I'm fick!

    ReplyDelete
  5. i need more computer science skill

    ReplyDelete
  6. "Step one" was yesterday, which indicated that installation might be a bitch. You must consult the oracle for the PATH.

    Wait, am I learning the absolute basics of Java or entering the Matrix?

    ReplyDelete
  7. I understood about every third word...heehee. But hey, I might know someone who would totally understand this stuff and be right into it. I'll be sure to pass it along!

    ReplyDelete
  8. I think the dentist numbed more than my gums today... I am lost.

    ReplyDelete
  9. I've been wanting to learn Java for a while now, I'll get started right after I eat this can of tuna.

    ReplyDelete
  10. huh? been some time since ive played with java.

    ReplyDelete
  11. I'm psyching myself up to 'Hello World.' Last time I did this, I was working on Q-Basic. Yeah, I'm old.

    ReplyDelete
  12. embedding youtube clips is about as high tech as I (and apparently others in this comment section) get sir!

    ReplyDelete
  13. Oh Sucio, can I handle this or do I need to just sit back and watch you Men create? Oi Vey!!

    ReplyDelete
  14. I've missed a few days of your wonderful posts, so forgive me. I'll be caught up soon :)

    ReplyDelete
  15. cool post - IDE's just make you lazy, so respect for learning it the notepad way

    ReplyDelete
  16. @ G - I'll switch to Netbeans or Eclipse once I'm more comfortable with the language. I assume they include some kind of object browsers - which I'm feeling the need for.

    One of the problems I'm having going the Notepad route is that it's hard to find stuff buried under mountains of worthless, machine-generated javadocs "documentation".

    Feels like being a Unix noob and having to scan through 50 pages of bullshit "man" docs to find out out to search for "string1 or string2".

    ReplyDelete
  17. Cool! I took a beginner Java class last year, but I'm sure I have much to learn. Following and supporting you, daily!

    ReplyDelete