Exercise 2: Fixing Errors in a Build
This exercise shows you how to quickly locate and fix the source line responsible for an error found during the build process. Build errors usually include incorrect language syntax, undeclared variables, and misspelled keywords.
If you have not yet added the code to bounce the words in the Blink project, you should do so now using the instructions in Editing Source Code.
Locating Errors
- Check the project manager for the name of the current project.
If the current project is not Blink, double-click on the Blink project name.
- Click the Build button
on the Java WorkShop main toolbar.
Java WorkShop compiles the Blink project using the Java WorkShop Java compiler by default; this compiler is faster than the standard JDK Java compiler.
The Build tab lists two errors. The source editor highlights the source line responsible for the first error in yellow.
Fixing Errors
- Fix the first error, in line 55, by adding parentheses around offset.
Your line should look like this:
if (offset)
- In the Build tab, select the second error Blink.java: 61
The source editor highlights the source line responsible for the next error.
- Fix the error by adding a ; after y = y / 2 in line 60.
Your line should look like this:
y = y / 2;
- Click the Save File
button in the Edit/Debug toolbar.
Your program should now be fixed and you can rebuild your program.
Rebuilding the Project
- Click the Build button
on the main toolbar.
You should not get any error messages. If you do, go back to the source editor and double-check your code to see if you typed in the information correctly.
- Click the Run button
on the Java WorkShop main toolbar.
Java WorkShop runs your project with the text bouncing up and down, in addition to blinking on and off.
Next lesson:
- You have completed the lessons in this tutorial. The next tutorial is Tutorial Four: Browsing a Project.