Thursday, October 15, 2009

Java Tutorial for Absolute Beginners

(I want to give programming newbies an introduction to Java, but in a way that they can do it independently such that the tools won't get in the way (eg. 'javac' to compile, 'java' to run, avoiding classpath issues, and so on). I think the best fit is to have them use Eclipse (or another Java IDE), which will allow them to get to the code quickly; hopefully the IDE won't distract them. Unfortunately, I cannot find any existing tutorials that fit the bill, so here's a set of instructions that I hope will work better.)

  1. Complete steps 1-4 of the Eclipse Java IDE tutorial. I assume you will be able to find and install Java and Eclipse (which are installed separately); when you choose a Java or Eclipse download, just choose a "Java" version... there's no need for anything fancy like "Java EE".
  2. Jump into "Part 2: The Syntax" of Brewing Java: A Tutorial, but stop when you get to "Command Line Arguments".
  3. In Eclipse, try to run the "Command Line Arguments" example, but realize that you'll get an error.

    In order to supply run-time data to your program, you'll have to add an argument to run it: right-click on your program and select "Run As...", but then instead of "Java Application" choose "Run...", then click on the "Arguments" tab and fill in something (like your name) and click "Apply".

    Now "Run" your program and you should get some good output.
  4. Now you can continue with Brewing Java: A Tutorial. If you get this far, you should be able to do the rest of any other tutorial out there.
Good luck!

No comments: