Compile All Java Programs in a Directory

Compiling a Program
Let us see a simple tip of compiling all Java programs in a directory with a simple shortcut. For compiling a normal Java program in a particular directory we go to that directory from command prompt and then we write,



javac filename.java

To compile all the java files in a directory, we can simply write,


javac *.java

The above command compiles all the java files (the files that end with .java extension). Isn't that simple? It helps when your project source files are in the same directory or even when working out with servlets where every source file usually exists in the same folder.

No comments: