I'm trying to compile a Java project from the command line. The project contains class files in different packages. The program compiles and run fine if I specify every java file of every package. Here's my directory structure:
toplevel/
mainFile.java
level1/ (Contains fileA.java)
Now if I do javac -classpath ./toplevel toplevel/mainFile.java toplevel/level1/fileA.java
, this compiles fine and I can run it with java toplevel/mainFile
.
Now if a create a new folder called 'level2' in level1 and create a class 'B' inside it, the new directory structure becomes:
toplevel/
mainFile.java
level1/ (Contains fileA.java)
level2/ (Contains fileB.java)
To compile this I have to do:
javac -classpath ./toplevel toplevel/mainFile.java toplevel/level1/fileA.java toplevel/level1/level2/fileB.java
which is becoming ridiculous. Is there an instruction that recursively compiles each package and the files inside it?