xhtml
 

Development using Commands

When developing programs, you spend a lot of time in the edit-compile-test cycle, so it is worth spending a little time working out how best to do it. The simplest option is command line development, which just means using the commands javac, java, and your favourite editor repeatedly in a shell window. For example:

> jedit Prog.java        ( create or edit the program file )
> javac Prog.java        ( try compiling it )
> jedit Prog.java        ( edit the program to fix a compiling error )
> javac Prog.java        ( compile )
> java Prog              ( run )
...

The main features of the command line approach are:

It is important to make your environment convenient and efficient, and to cut down the amount of typing you do, to avoid RSI if nothing else. You can do that by customising your environment, e.g. using history and completion features of shells. See:

Customising Unix (includes Linux)
Customising Windows

For larger programs made out of several files, there is a further problem beyond the edit-compile-test cycle. You have to decide which files to compile, and how to combine them for testing. Although there are tools like make and ant for this, you often don't need them because the javac command itself sorts out most of these problems for you. If you have several files where the main program file is Main.java, and you edit one or two of the files, you still only have to type javac Main.java to get them compiled. The javac command will work out which files need recompiling for you.


Back