[Updated: Dec 22, 2010]
I've always had some trouble remembering the right commands to compile a large-ish Java project from the command line when you don't have Ant at your disposal.
So I thought I should write about it so others (including myself) might find it handy for future reference.
The general idea is to have this kind of directory structure (duh!):
/myproject /src /classes /lib
The batch file. Make changes to match your directories.
The last 2 lines create a simple txt file of all your
.javafile names in the
srcfolder. It then uses the
javaccommand to compile them into the
set basedir=c:\projects\myproject del /Q %basedir%\classes mkdir %basedir%\classes set cp=%basedir%\lib\XXX.jar;%basedir%\lib\YYY.jar;%CLASSPATH% set JAVA_HOME=C:\Programs1\jdk1.6.0 set PATH=%JAVA_HOME%\bin;%PATH% dir /b /s %basedir%\src\*.java > %basedir%\java_files_to_compile.txt %JAVA_HOME%\bin\javac -classpath %cp% -d %basedir%\classes @%basedir%\java_files_to_compile.txt xcopy /S %basedir%\src\*.properties %basedir%\classes jar -cvfm %basedir%\myproject-lib.jar %basedir%\manifest.mf -C %basedir%\classes/ .