English
Wrapper scripts
While unlikely, it's still possible that you encounter a project whose build is managed by plain old Makefiles. They contain a list of targets which consist of commands (marked with tab at the begining of line) and are invoked by `make` _target_ or simply `make` to run the default target.
What is the difference between JVM and Java?
What is the difference between `java` and `javac` comands?
What is a pom.xml file and what information it contains?
What is a CLASSPATH environment variable and how can you use it?
What are contents of a typical `JAR` file?
To illustrate certain points we artificially complicate things by creating:
To better illustrate various parts of Java packaging we will dissect simple Java ``Hello world'' application. Java sources are usually organized using directory hierarchies. Shared directory hierarchy creates a namespace called `package` in Java terminology. To understand naming mechanisms of Java `packages` see link:http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html[Java package naming conventions].
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:
The sample project can be compiled to a bytecode by Java compiler. Java compiler can be typically invoked from command line by command `javac`.
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].
The classpath is a way of telling JVM where to look for user classes and 3rd party libraries. By default, only current directory is searched, all other locations need to be specified explicitly by setting up CLASSPATH environment variable, or via `-cp` (`-classpath`) option of a Java Virtual Machine.
Telling JVM which Java class contains `main()` method
<target name="init" description="Create build directory">
<mkdir dir="${build}"/>
</target>
<target name="dist" depends="compile"
description="Generate jar">
<mkdir dir="${dist}/lib"/>
<target name="compile" depends="init"
description="Compile the source">
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="clean" description="Clean build files">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
Some projects that use Apache Ant also use Apache Ivy to simplify dependency handling. Ivy is capable of resolving and downloading artifacts from Maven repositories which are declaratively described in XML. Project usually contains one or more `ivy.xml` files specifying the module Maven coordinates and its dependencies. Ivy can also be used directly from Ant build files. To detect whether the project you wish to package is using Apache Ivy, look for files named `ivy.xml` or nodes in the `ivy` namespace in project's build file.
Setting the classpath