<<Previous | ToC | Next >>
Before you can program a computer, you need to be able to use it, that
is, you need to be reasonably skillful at clicking and dragging and double-clicking
and drag-selecting and copying and pasting and (of course) typing into
fields in windows. You need recent a Windows (Win7 or later) or OSX
(again, x.7 or later) computer to do this on. You could do it on Linux
or an earlier computer, but it's harder; save that for after you get good
at it (if you still want to). It also helps if you understand mathematical
formulas and maybe a little algebra, but not much.
This isn't really what programming a computer is all about, but the people who make these things figure that if they make the hurdles hard enough for you to climb over, you won't come take their job away. It's nonsense of course, there's plenty of work for everybody, but there you go. The 18-wheeler of Java development environments, with all kinds of levers and knobs to confuse you and make itself totally unusable, is Eclipse, which is really hard to use. I will touch briefly on how to make it work (and how to recover when it gets lost) later when you are more comfortable with the real nuts and bolts of programming, but for now we'll use a student environment that's somewhat simpler, called "BlueJ." Unfortunately the BlueJ people have fallen into the "Creeping Feature Creature" syndrome -- that's where, like the selfish French royalty when told "The people have no bread," responded "Let them eat cake," as if a higher-priced product solves the problem of inadequate resources -- so some of what you see may be slightly different from what I tell you.
Unfortunately -- especially with incompatible software releases like
these later BlueJ and Java versions -- it's really easy to do something
catastrophic to your computer that you cannot recover from. If you are
doing this on your own have a computer geek friend, I would suggest you
ask him (geeks tend to be guys) to install it for you. If you are doing
this in a formal NWAPW setting, the instructor can
install it. If you are not so lucky, you can protect yourself by making
a system backup (see my instructions for Backing
Up Windows 10 or my rather skimpy notes on Backing
Up OSX) before you install any unstable code like
Java or BlueJ (which uses Java). Some computers already have Java installed,
you need to find a BlueJ version that works with it. Good luck finding
out what version you have installed. Like I said, the folks doing this
stuff do not want to be helpful.
Then you need the "StartHere" project for this class, which you can download here. It's a zip file that both Windows and OSX know how to open. That gives you a "StartHere" folder that you should add to the BlueJ folder, like this:
It's a tradition among C programmers (and their derivatives, like Java) that the first program you always write when learning a new programming language or development tool, is the minimum program that you can tell if it ran correctly, which is a program that prints out something like "Hello World!" and then quits. That is what this program does. Click the "Compile" button. That is what translates this program into machine language. It will tell you at the bottom of the window something like "Class compiled - no syntax errors". The "no syntax errors" part is what you need to see. If you see anything else there (and you didn't make any changes) something went badly wrong, get help. If you accidentally bumped the keyboard, you might be able to choose "Undo" from the Edit menu, or (more robustly) Quit/Exit out of BlueJ, throw away the StartHere folder (drag it into The trash or Recycle) then restart in the previous paragraph with downloading the "StartHere" (unless you still have it) and unzipping it.
After your "Class compiled" you can bring the other window to the front and right-click the yellow "Hello" icon to pop up a menu of things you can do it. Choose the "void main()" item to run your program:
This opens a third window, with the text "Hello World!" at the top. That is what the program did. OK, you didn't write it, you just ran what I wrote. Go back to the program window (2-click the yellow "Hello" icon again), then select only the green text "Hello, World" inside the quotes on the line that is marked "REPLACE THIS LINE" and replace it with something else, whatever you want to computer to say. Compile it and run it again. Now it's your program running. On the next page we will analyze what is happening, so you can understand it and not merely copy and paste.
Next: Sequence & Output
<<Previous | ToC | Next >>
Revised: 2020 September 17