In this demo I'm going to show you how to
compile Java source files
at the Windows command prompt
without using BlueJ.
To add a source code can be compiled
at the command prompt using the javac command
that's available if you have the Java SDK
installed on your computer.
When BlueJ compiles a class
it uses the javac command,
it just hides the details from you.
I have a folder containing Java source files
for all the classes in the adventure game programme.
I can list the contents of that folder
and you can see the source files there.
Let's try compiling the Item class,
type the command javac then Item.java and return.
I don't get any message which is a good thing
because javac only will give me messages
if there are compilation errors.
Lets list the contents of the folder now
and you can see there's a new file item.class
which contains the compiled item class.
I can compile all the classes in the folder
at once using a wildcard.
Type javac *.java and return and again
there's no message so compilation has been successful.
If I list the contents of the folder you can see that
there's now a class file for everyone of the source files.
Finally, I'm going to run the programme.
In the previous demo
I showed you how to run a Java programme
packaged as a jar file and that's
normally the most convenient way to run a programme.
However, you can run a programme
by using the Java command and specifying
the name of the class that contains the main method.
This will work if compiled class files are available
for all the classes that the programme needs.
So lets try that,
java and the name of the class with the main method
is Game and enter and a welcome message is shown
and we can just
go through the rest of the programme as before.