Environment setup consists of two main parts:
Telling JVM which Java class contains `main()` method
Adding required JAR files on JVM classpath
Compiling our project
The sample project can be compiled to a bytecode by Java compiler. Java compiler can be typically invoked from command line by command `javac`.
$ javac $(find -name '*.java')
For every `.java` file corresponding `.class` file will be created. The `.class` files contain Java bytecode which is meant to be executed on JVM.
One could put invocation of `javac` to Makefile and simplify the compilation a bit. It might be sufficient for such a simple project, but it would quickly become hard to build more complex projects with this approach. Java world knows several high-level build systems which can highly simplify building of Java projects. Among the others, probably most known are http://maven.apache.org/[Apache Maven] and http://ant.apache.org/[Apache Ant].
See also xref:maven.adoc#maven[Maven] and xref:ant.adoc#ant[Ant] sections.
JAR files
Having our application split across many `.class` files wouldn't be very practical, so those `.class` files are assembled into ZIP files with specific layout called JAR files. Most commonly these special ZIP files have `.jar` suffix, but other variations exist (`.war`, `.ear`). They contain:
Compiled bytecode of our project
Additional metadata stored in `META-INF/MANIFEST.MF` file
Resource files such as images or localisation data
Optionaly the source code of our project (called source JAR then)
They can also contain additional bundled software which is something we don't want to have in packages. You can inspect the contents of given JAR file by extracting it. That can be done with following command:
jar xf something.jar
The detailed description of JAR file format is in the link:http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html[JAR File Specification].