Java Reference
In-Depth Information
Depending on your platform, you might need to add the JDK's
bin
directory
to your “path.” We'll look at what that means and how you do it in the next
section.
But first let's try a little exercise and see if it works.
Try This Yourself
With the JDK installed, you can now run that test program you typed in.
Again, this is just a simple program to make sure Java is happy. It's not a
Minecraft plugin yet, but it's a start. As soon as you get this working, you'll
be ready to start building Minecraft plugins.
cd
to your Desktop and make sure the
CreeperTest.java
file is there:
$
cd Desktop
$
ls
CreeperTest.java
Now run the Java compiler on
CreeperTest.java
by executing the
javac
(Java
compiler) command.
$
javac CreeperTest.java
$
ls
CreeperTest.class CreeperTest.java
The
javac
program first checks to make sure it understands everything you
typed in the
CreeperTest.java
file. If there are no mistakes, then it creates the
binary class file.
But the odds are that most of the time
there will be mistakes.
Don't worry if
you get a ton of error messages: you didn't break your computer. Programming
languages like Java are notoriously picky about capitalization, punctuation,
and all the other things we type in that file.
Remain calm. (That, by the way, is generally good advice when working with
computers.)
Try to decipher the message the computer gives you, and double-check all
the code against our example from a moment ago. We'll walk through several
likely problems next. There's also some advice in
Appendix 1,
How to Read
Error Messages
, on page 211
.If all else fails, don't forget this topic has a website
where other folks are wrestling with this stuff too!
4
Once
javac
happily finishes its work without errors, you're ready to run.
4.