The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
To generate a self-contained application bundle for each platform on which your application runs, you must run the packaging tool on each platform. You have the option of using platform-specific build files or setting up one build file that can be run on all platforms. Platform-specific files can be simpler to set up, but then you must maintain multiple files.
The File Association Demo described in Using File Associations uses a single build file that works on all platforms.
The following elements of the build file support its use for all platforms:
The main class for the application is ScriptRunnerApplication.java
for Linux and Windows and ScriptRunnerApplicationMac.java
for OS X. The following code in the -pre-init
task is used to determine which class to use:
<condition property="main.class" value="sample.fa.ScriptRunnerApplication" else="sample.fa.ScriptRunnerApplicationMac"> <not><os family="mac"/></not> </condition>
The following code in the -pre-init
task is used to prevent the main class for OS X from being compiled when running on Linux or Windows:
<condition property="excludes" value="**/*Mac.java"> <not><os family="mac"/></not> </condition>
<fx:bundleArgument> elements are used to pass arguments to the different bundlers available. Arguments that are not used by a bundler are ignored, so the build file can contain the arguments needed by all platforms. The following code defines arguments for Linux, OS X, and Windows:
<fx:bundleArgument arg="classpath" value="FileAssociationsDemo.jar lib/groovy-all-2.3.8.jar"/> <fx:bundleArgument arg="win.exe.systemWide" value="true"/> <fx:bundleArgument arg="linux.bundleName" value="file-association-demo"/> <fx:bundleArgument arg="email" value="maintainer@example.com"/> <fx:bundleArgument arg="mac.CFBundleName" value="File Assoc Demo"/> <fx:bundleArgument arg="win.menuGroup" value="Java Demos"/>
See build.xml
for the complete build code.
You can download the source files for the File Association Demo from Self-Contained Application Examples.