Free and Easy Java |
by Dave Mulkey,
Germany, 2004-2007 |
~~ Purpose ~~ Tools ~~ Installation ~~ Test Program ~~
~~ Simple Sample Programs ~~ Reading and Resources ~~ More Questions ~~
These notes are intended to help IB Computer Science teachers and students to get started with the new Java based IB syllabus. Most of the stuff here is free and easy. Later you may want to move on to expensive and difficult. (I haven't reached that stage yet.)
To start programming in Java, you need 3 tools:
Processing (beta) is a simplified Java IDE for beginners, especially those with no technical background. It includes the jikes compiler, so it runs without any installation. It was written for graphic artists who want to learn a little bit about programming. The authors have removed all the start-up difficulties by having the IDE auto-generate the import commands, the public_static_void_main methd, and a few other things. They also added some simplified commands in library classes, like loadStrings() to read a bunch of Strings from a text-file into an array. They have a very nice reference page at: http://www.processing.org/reference/index.html
It produces applications AND applets (including a simple .html file) automatically. You can write a single Java command and run it immediately, without coding an entire class. The download includes the compiler (if you want). It says it runs on Windows, Linux and Mac, but I've only tried out the Windows version.
Highly recommended for Java beginners. Download at: http://www.processing.org/download/index.html
*Caution - it's a bit "non-standard", so it might be tricky using it with a "standard" Java textbook. You probably wouldn't use this for the entire IB course - maybe change to BlueJ after a couple months.*
The standard solution involves two downloads:
I like DrJava - it makes it easy for beginners to start because
There are many similar IDEs (with syntax highlighting, structure outlines, project management, etc). We use BlueJ - I think that is the best choice for IB projects, but maybe not the easiest to start with.
You can get all 3 pieces in a single (large) download from Sun Microsystems at:
You wlll get the NetBeans IDE and Sun's compiler and JVM. This is a very large download (over 100 MB). My students like NetBeans. The editor does real-time syntax error-checking, underlining errors with red squiggles, like a word-processor.. The visual GUI designer is attractive, but the whole system is so large and complex that high school students can easily get lost. This might make sense in the second year of IB, but I can't see using it at the beginning. It also needs a fairly high-spec PC to run at a reasonable speed.
Best choice for students?
I allow my students to choose the IDE they like best. I encourage them to use BlueJ, but many opt for JGrasp. They try NetBeans, and they like it, but it's kind of slow so they usually settle on a smaller, quicker editor.
Install the JDK ( compiler and JVM) first. Then a clever
IDE (like JCreator or BlueJ) will find the compiler automatically.
Beginning Java programmers might have trouble setting up the
IDE to correctly find their .java files and Sun's compiler.
If you have trouble, try these hints:
Stick to making applications at first. Applets are attractive, but they have numerous compatibility problems - beginners should avoid this.
The name of the class (in public class Name) must match the file name used for saving (Name.java). It must match exactly - Java is case-sensitive.
There are no useful input commands for text-mode applications. Forget text-mode and start right away with AWT or Swing GUI apps. It's easier, and a lot more useful in the long run. DOS is dead - Windows wins.
Here are some sample programs. Click the links to see
explanations and source code. You should be able to copy the
source code and paste it into an IDE.
Getting Started |
Calculations |
Loops and Decisions |
Complete Program |
Easy IO |
Easy Apps |
EasyIO |
EasyApp |
** Warning **
The code in the sample programs is not "industrial strength". It is intended only for demonstration purposes. It may contain errors. It is highly simplified to meet the needs of beginners.
The same goes for the explanations. Explanations are written with beginners in mind. The explanations are highly simplified and avoid the "correct" techie-jargon. There are plenty of hyper-technical explanations in the references listed below.
The EasyApp programs are using the original (old) version of EasyApp. The new version is available on my web-site at http://ibcomp.fis.edu/Java/EasyApp.html
I'd be happy to hear about any mistakes in the samples - please report them to Dave_Mulkey@fis.edu
Once the compiler and IDE are set up and running, you'll probably want a book or tutorial to learn the Java language. We've used all the following successfully in our classes:
Free Tutorials/Online Books
Commercial Books - not free but worth the price
Reference and Help Files
Java Web-Sites - Sample Programs and Other Stuff
A Google search will quickly turn up lots more free resources.
If you send an e-mail to Dave_Mulkey@fis.edu (there's an underscore in Dave_Mulkey), or post it on the IB Online Curriculum Center forum, I'll try to answer it.