JAVA Setup
In order to write, compile, and run Java programs you need two pieces of software:
- A text editor in which to type your code
- Java Development Kit (JDK) to compile and run Java code
The text editor we will begin with is BlueJ. It's an excellent editor designed for education and it includes the JDK so you have nothing else to download and configure. One step. Easy!
Click here to download and install BlueJ
Test your Java installation.
If everything goes smoothly, you will see "Hello World!" displayed in BlueJ's terminal window.
Install the gpdraw library.
- A library is a collection of pre-compiled code organized into a .jar file.
- We will be using the grdraw library for easy-to-use drawing capability in our programs.
- Download gpdraw.jar and save it to your desktop or wherever you can find it later.
- Next, open BlueJ's Preferences menu. (To get there, first make sure you're in the main BlueJ window that has the boxes showing each class. Then, if you're on a PC, select Tools-->Preferences. If you're on a Mac, select BlueJ-->Preferences)
- Select the Libraries tab. In the Libraries tab, select Add File and then select gpdraw.jar from wherever you downloaded it.
- After pressing OK, you are warned that the changes will not take effect until the Java Virtual Machine (JVM) is restarted. To restart the JVM select Tools-->Reset Java Virtual Machine from the menu or click the u-turn arrow in the bottom right corner of the main BlueJ window.
Test your gpdraw installation.
- Make sure you have reset the Java Virtual Machine as described above.
- Download DrawingTest.java by right-clicking the link and selecting Save link as (or Save Target As). Choose a location you can find easily.
- Add the file to your project by selecting Edit-->Add Class from File in the BlueJ menu.
- Compile and run the program the same way you did for HelloWorld.
If everything goes smoothly, you will see a triangle drawn in a window named DrawingTool.