View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Errors found by DrJava and their causes

Error with the zip file with Java 1.6 (6.0) and DrJava.

There is a problem when you use Java 1.6 with the latest version of DrJava. If you start it with
the executable (drjava-stable-yearXXXX-XXXX.exe) you get an error about the zip file. You can fix this by downloading the jar file from
http://www.drjava.org. This is an executable jar file so you should be able to double click on it to execute DrJava. But, some people
have unzip software that unzips it instead. If this happens download the following bat file and click on the bat file to start DrJava.
drjava.bat You may want to edit this file to make sure that it matches your version of DrJava. The bat file is configured for
drjava-stable-20080106-0744.jar



Error:
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

This problem is due to having both Java 1.4 and 1.5 on your machine. Please use Java 1.5 instead of 1.4.
Instructions for setting DrJava to use 1.5


Error: Undefined class or can't find symbol

Causes: Spelling the class name wrong, wrong capitalization, or a failure to import a class or use the fully qualified class name.

If you want to use the Color class from the package java.awt then you should import java.awt.Color or java.awt.* or use the fully qualified name of java.awt.Color.

You don't need to import classes in the package java.lang but you do need to import classes in all other packages. Remember that importing one package does not import all other packages that begin the same. For example, importing java.awt.* does not import classes in java.awt.event.*


Error: No 'x' method in 'y'

Causes: Check the spelling and capitalization of the method name. If that is correct check the parameters being passed to the method and make sure that there is a method that takes these parameters in the specified order. If that is correct check that the method isn't private and you are trying to call it from outside the class.


Error: Redefintion of 'x'

Cause: You declared a variable more than once in the same scope (like in the interactions pane or in a method). You can reuse variables but you can't declare them more than once in the same scope. Just leave off the type to stop from redeclaring them.


Error: 'class' or 'interface' expected.

Cause: You probably tried to put a method after the end of the class definition. All methods must be defined inside the class definition (before the last closing curly brace in the file).


Error: illegal start of expression.

Casue: You may have tried to put one method definition inside of another. Methods needs to be declared inside the class definition but not inside another method.

Error: ';' expected.

Cause: You forgot to end a statement with a ';' Remember that statments in Java end with a ';' like sentences end in English with a period.


Error: java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!

Cause: you used an invalid index when trying to access an array element. Remember that the first array element is at index 0 and the last at length - 1. For two dimensional arrays the last array element in the x direction is at width - 1 and the last array element in the y direction is at height - 1.

Example in DrJava interactions pane:

> Picture p = new Picture(Picture.getMediaPath("caterpillar.jpg"));
> System.out.println(p.getWidth());
329
> System.out.println(p.getHeight());
150
> p.getPixel(330,160);
java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source)
at java.awt.image.BufferedImage.getRGB(Unknown Source)
at SimplePicture.getBasicPixel(SimplePicture.java:247)
at Pixel.setValuesFromPictureAndLocation(Pixel.java:137)
at Pixel.(Pixel.java:57)
at SimplePicture.getPixel(SimplePicture.java:270)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
>


Error: Compile exception: java.lang.OutOfMemory Error

This means that the amount of memory that was set aside for the Java Virtual Machine
to use was too small for what you are doing. You might be working with a very large
picture. You can shrink the picture or ask for more memory for Java.

You can change this by adding some arguments
for the Java Virtual Machine when you start it. In Dr-
Java you do this by clicking on Edit then Preferences
which will display the Preferences Window. Click on
Miscellaneous under Categories on the left and then
enter -Xmx512m -Xms128m in the JVM Args for Interactions textfield
to set the maximum amount of
memory to 512 megabytes and the starting memory to 128
megabytes.

Uploaded Image: addMemory.jpg

Then click on OK. It may ask you if you re-
ally are sure that you want to do this and you should say
OK. Click on Reset to have the new settings affect the
Interactions Pane.

Uploaded Image: confirm.jpg

You can actually set the maximum to more RAM memory
than you have. It will save some of the items in memory to
disk and bring them back in when they are needed. This
is called virtual memory.


Links to this Page