如何添加.jar文件到本地捆绑? [英] How to add a .jar file to native bundle?

查看:140
本文介绍了如何添加.jar文件到本地捆绑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是创造的JavaFX 2.2的应用程序,并在编译本地捆绑软件(EXE)我可以看到,在运行时我错过了一个图书馆,我需要。

Hi i'm creating an application in javafx 2.2 and while compiling a native bundle (EXE) I can see that in the Runtime I miss a library I need.

MyApp的\\运行\\ JRE \\ lib目录\\分机\\程序(sunjce_provider.jar)

MyApp\runtime\jre\lib\ext\sunjce_provider.jar

我尝试在我的build.xml加入像这样

I try adding it like this in my build.xml

<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
            nativebundles="exe"
           outdir="${basedir}/${dist.dir}" outfile="${application.title}">
    <fx:application name="${application.title}" mainClass="${javafx.main.class}"/>
    <fx:resources>

        ...

        <fx:fileset dir="${platform.home}/jre/lib/ext" includes="sunjce_provider.jar"
                type="data"/>

    </fx:resources>
    <fx:info title="${application.title}" vendor="${application.vendor}"/>
</fx:deploy>

但是,这只是离开它在

But that only leaves it at

MyApp的\\应用程序\\程序(sunjce_provider.jar)

MyApp\app\sunjce_provider.jar

有没有办法做到这一点?

Is there a way to accomplish this?

推荐答案

包括应用程序库

本节展示了如何将您的应用程序依赖于标准的罐子。

This section shows how to include standard jars which your application relies upon.

示例build.xml从JavaFX的Ant任务参考片段中,重点线为&LT; FX:文件集DIR =DIST包括=LIB / *罐子/&GT;

Sample build.xml snippet from the JavaFX ant task reference, the key line is <fx:fileset dir="dist" includes="lib/*.jar"/>:

<!-- Expect definition of JavaFX ant tasks is already imported -->

<fx:jar destfile="dist/application.jar">
    <!-- Details about application -->
    <fx:application name="Sample JavaFX application"
            mainClass="test.MyApplication"/>

    <!-- Define what auxilary resources are needed -->
    <fx:resources>
        <fx:fileset dir="dist" includes="lib/*.jar"/>
    </fx:resources>

    <!-- What to include into result jar file?
         Everything in the build tree -->
    <fileset dir="build/classes"/>

    <!-- Customize jar manifest (optional) -->
    <manifest>
        <attribute name="Implementation-Vendor" value="Samples Team"/>
        <attribute name="Implementation-Version" value="1.0"/>
    </manifest>
</fx:jar>   

修改JRE组件

本节将向您展示如何定制捆绑在一起您的应用程序的Java运行时组件。

This section shows you how to customize the the Java runtime components that are bundled with your application.

查看 Java部署博客上,包括原生包装太阳JCE提供者(注意问题:<一href=\"http://stackoverflow.com/questions/13896261/sunjce-provider-jar-in-jre-for-standalone-javafx-application\">sunjce_provider.jar在JRE为独立JavaFX应用程序)。

See the Java Deployment blog on including the sun jce provider in native packaging (noted in question: sunjce_provider.jar in jre for standalone javafx application).

相关章节(复制和博客条目粘贴)是:

Relevant sections (copy and pasted from the blog entry) are:

如果您正在使用的包装工具,以产生有可安装的软件包可能是一个需要调整图像应用程序之前,包装到安装程序。为什么?例如,您可能要签名的应用程序,因此它不会似乎是不可信的操作系统(例如讨好的Mac OS X网闸)。

If you are using packaging tools to produce an installable package there could be a need to tweak the application image before it is wrapped into the installer. Why? For example you may want to sign the application, so it does not appear to be untrusted to the OS (for example to please Mac OS X Gatekeeper).

此外,默认情况自包含的应用程序不包含Java运行时的完整副本。我们只包括设置强制性组件。为什么被带到这种做法的部分原因是,我们要减少封装尺寸。不过,也有您的应用程序可能依赖于这些可选组件,并在这种情况下,你需要一种方法来将其添加到私人运行时的情况。例如HTTPS如果JRE / lib / ext目录/程序(sunjce_provider.jar)丢失连接将无法工作。

Also by default a self-contained application does not contain full copy of Java Runtime. We only include set of mandatory components. Part of the reason why this approach was taken is that we want to reduce the package size. However, there are situations where your application may depend on these optional components and in that case you will need a way to add them to the private runtime. For example https connections will not work if jre/lib/ext/sunjce_provider.jar is missing.

目前这可以通过提供填充应用图像后所执行的自定义配置脚本来实现。如上面带有图标的例子,你需要启用详细输出找到脚本文件的名称,然后将其拖放到打包工具会发现它的位置。需要注意的是脚本语言是特定于平台了。目前我们只支持Windows的Mac / Linux和Windows脚本外壳。

Currently this can be achieved by providing a custom config script that is executed after application image is populated. Like in the example above with the icon, you need to enable verbose output to find the name of the script file and then drop it to the location where packaging tools will find it. Note that scripting language is platform specific too. Currently we only support shell for Mac/Linux and Windows Script on windows.

你如何找出应用程序映像所在?目前,自定义脚本在配置文件存储,但应用程序映像可以使用相对特定平台的路径访问的目录中运行。您可以从获得详细的输出或通过环境变量JAVAFX_ANT_DEBUG设置为true,这条道路保持中间构建构件。

How do you find out where the application image is located? Currently custom scripts are run in the directory where config files are stored but application image can be accessed using relative platform specific path. You can derive this path from verbose output or by setting environment variable JAVAFX_ANT_DEBUG to true to keep intermediate build artifacts.

下面是示例脚本(贡献的约翰·彼得森),你可以用它来的jre / lib / ext目录/加把sunjce_provider.jar的MyApp到了Windows平台上的应用程序包。脚本使用Javascript,但你也可以使用Windows的VBScript脚本。

Here is sample script (contributed by John Petersen) you can use to add jre/lib/ext/sunjce_provider.jar to the application package of MyApp on the Windows platform. Script using Javascript but you could also use VBScript for Windows scripting.

<?xml version="1.0" ?>  
<package>  
   <job id="postImage">  
    <script language="JScript">  
     <![CDATA[  
        var oFSO = new ActiveXObject("Scripting.FileSystemObject");  
        var oFolder = oFSO.getFolder(".");  
        var from = oFolder.path + "\\MyApp\\app\\sunjce_provider.jar";  
        var to = oFolder.path + "\\MyApp\\runtime\\jre\\lib\\ext";  
        if (!oFSO.FolderExists(to)) {  
          oFSO.CreateFolder(to);  
        }  
        to += "\\";  
        oFSO.CopyFile(from, to);  
     ]]>  
    </script>  
   </job>  
</package> 

这篇关于如何添加.jar文件到本地捆绑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆