本文介绍了将自定义uri方案与Windows的Java自包含应用程序相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自包含的JavaFX应用程序.为了改善用户体验,我希望用户单击浏览器上的按钮/链接并启动应用程序.就像torrent的磁铁URI一样,该链接包含启动应用程序所需的元数据.

I have a self contained JavaFX application. For an improved user experience, I would like the user to click on a button/link on the browser and start the application. Just like magnet URI for torrent, the link contains metadata that is required to start up the application.

是否有一种方法可以生成JavaFX应用程序的可执行文件,以与自定义URI关联,就像与torrent应用程序关联的磁石URI一样.

Is there a way to generate the executable for JavaFX application to associate with custom URI just like magnet URIs associated with torrent applications.

推荐答案

以下是如何将自定义URI与应用程序相关联.

Here is how to associate custom URIs with an application.

我已经有一个生成本机包的任务.

I already have a task that generates the native bundles.

第一步是在您的ant任务中启用详细信息,以便您可以找到构建路径.如此处所述,在6.3.3中启用仔细查看并在生成目录中查找<AppName>.iss文件,该文件通常为AppData/Local/Temp/fxbundler*.

First step is to enable verbose in your ant task so you can locate the build path.As mentioned here, in 6.3.3 enable verbose and look for <AppName>.iss file in the build directory, which is usuablly AppData/Local/Temp/fxbundler*.

确保在类路径中具有包含包目录的目录.这是一个如何将其添加到类路径的示例:

Make sure you have the directory that contains package directory in the classpath. Here is an example of how you can add that to the classpath:

<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${build.src.dir}:${JAVA_HOME}/lib/ant-javafx.jar"/>

在我的示例中,我在src目录中有带有Drop-In Resources的程序包/窗口.

In my example I have package/windows with Drop-In Resources in src directory.

如果您具有文件关联,您将看到类似以下内容的内容:

If you have file association, you will see something like this:

[Registry]
Root: HKCR; Subkey: ".txt"; ValueType: string; ValueName: ""; ValueData: "AppNameFile"; Flags: uninsdeletevalue

仅在此行之后,您可以添加行以添加自定义URI的注册表项.

Just after this line you can add lines to add custom URI's registry entries.

如果您没有文件关联,则将在

If you don't have file association then you will add entries after

ArchitecturesInstallIn64BitMode=ARCHITECTURE_BIT_MODE

您可以在以下位置找到如何生成AppName.iss文件的模板:C:\Program Files (x86)\Java\jdk1.8.0_60\lib\ant-javafx.jar\com\oracle\tools\packager\windows\template.iss

You can find the template of how AppName.iss file is generated at this location:C:\Program Files (x86)\Java\jdk1.8.0_60\lib\ant-javafx.jar\com\oracle\tools\packager\windows\template.iss

此处,您会发现如何编写类似上面的

Here you will find how to write lines like the one above

此处,您可以找到什么注册表项和条目.

Here you can find what registry keys and entries that needs to be added for custom URI association.

这篇关于将自定义uri方案与Windows的Java自包含应用程序相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 04:12