Java Reference
In-Depth Information
javac: Missing Semicolon
src/helloworld/HelloWorld.java:6: ';' expected
import net.canarymod.chat.MessageReceiver
We forgot the semicolon at the end of the import line. It should be this:
import net.canarymod.chat.MessageReceiver;
However, this error message isn't always foolproof. For instance, if I leave off
the opening brace, {, of a code block by mistake, like this:
public void disable()
log.info( "Stopping." );
}
I'll get a slew of errors, starting with “missing semicolon” and continuing on
to the next several lines of code, past our initial error:
src/helloworld/HelloWorld.java:18: ';' expected
public void disable()
^
src/helloworld/HelloWorld.java:21: class , interface, or enum expected
public void helloCommand(MessageReceiver caller, String[] parameters)
^
...
The compiler is confused: it thinks maybe we should have had a semicolon
after onDisable() , but actually we needed an opening brace, {. Then it has no
idea what's supposed to be happening, and it starts complaining that the
entire rest of the file is not what it expected.
That's why in most cases you only want to read the first one or two errors
and ignore the rest for the moment, as many of the following errors will dis-
appear once you fix the first one.
 
 
Search WWH ::




Custom Search