<<Previous | ToC | Next >>
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 have a computer geek friend, I would suggest you ask him (geeks tend to be guys) to install it for you. 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.
Unless it's already installed on your computer, you need to navigate over to the BlueJ website and download whichever "BlueJ Installer with Java JDK" is appropriate for your computer (they have it for both Windows and OSX, including older versions; they also have something for Linux, but it's not the same). The Windows download is an installer that you can run. What you get for OSX is a GNU Zip file (".gz") that OSX knows how to unpack. The result in both cases is a folder with two items in it. 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 your this program into machine language. It will tell you at the bottom of the window "no syntax errors." If you see anything else there, something went badly wrong, get help.
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 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: 2019 December 23