Java Project Template

Attached to this post is a tar.gz file that contains a complete template with which you can build a Java project.  It includes the directory structure, sample ant build.xml, logging configs, and shell scripts (and the beginnings of some Windows scripts) to run the program:

java_project_template/README.txt
java_project_template/conf/
java_project_template/conf/log4j.properties
java_project_template/lib/
java_project_template/lib/log4j-1.2.16.jar
java_project_template/launch.sh
java_project_template/scripts/
java_project_template/scripts/run.sh
java_project_template/scripts/run.vbs
java_project_template/scripts/run.bat
java_project_template/src/
java_project_template/src/com/
java_project_template/src/com/ryanchapin/
java_project_template/src/com/ryanchapin/samples/
java_project_template/src/com/ryanchapin/samples/java/
java_project_template/src/com/ryanchapin/samples/java/Example.java

The ant build file will create a build/classes directory into which all of the Java .class files are compiled.  It will also create a dist directory into which all of the jars, configs, and scripts to run the program are placed.

The run.sh script will dynamically concatenate the classpath argument for java based on the contents of the dist/lib/ directory and can be customized to accept any additional command line arguments that you may require.

The conf/ directory includes a log4j.properties file to get you started.

The build.xml file includes default, clean, and dist targets and does all of the basics needed to build your project.

The launch.sh script is used primarily during development to invoke run.sh without having to cd into the dist folder each time it is run.

Leave a Reply