Java 教程是为 JDK 8 编写的。本页中描述的示例和实践未利用在后续版本中引入的改进。
Self-contained applications include everything that an application needs to run. If your application requires an external library, that library can be added to the bundle for the application. Adding the library can be done in different ways.
The File Association Demo described in
Using File Associations downloads the Groovy library as part of the build process. The library is placed in the /lib
directory in the project for the application. This directory is then copied to the /dist
directory from which the self-contained application bundle is generated.
The following code in the -pre-init
task in the build.xml
file shows how the library is downloaded:
<!-- download and copy groovy library --> <copy toFile="lib/groovy-all-2.3.8.jar"> <resources> <url url="http://central.maven.org/maven2/org/codehaus/groovy/groovy-all/2.3.8/groovy-all-2.3.8.jar"/> </resources> </copy>
See
build.xml
for the complete build code.
You can download the source files for the File Association Demo from Self-Contained Application Examples.