5 Replies Latest reply: Apr 30, 2013 7:06 AM by sselvia RSS

    JavaFX Packager not including the jre/lib/ext folder in the resulting App

    sselvia
      When building a native application using Netbeans 7.3 on Mac OS X 10.8.3 and using JDK 7 update 21 the bundled app does not have the jre/lib/ext folder. This is causing a problem for my application since I'm using commons codec and bouncy castle. I have to add the ext folder manually to the app, which is a work around. The app in the DMG must always be updated to include the ext folder which defeats the purpose of the installable image.

      Any better work arounds for a NB 7.3 JavaFX project other than adding the ext to the app contents after it is created?
        • 1. Re: JavaFX Packager not including the jre/lib/ext folder in the resulting App
          bouye
          Instead of relying on automatic JAR discovery using the extension mechanism, manually add the JAR(s) of whatever lib(s) you are using to your project as a dependency, this way they'll be included in the bundled image.
          • 2. Re: JavaFX Packager not including the jre/lib/ext folder in the resulting App
            DrClap
            Agreed. I've seen numerous reasons to avoid using the extension mechanism and this is yet another reason.
            • 3. Re: JavaFX Packager not including the jre/lib/ext folder in the resulting App
              sselvia
              I had already tried that and I keep getting the same exception that the PBEWithMD5AndDES is not found. Also, that is not the point, the javafx packager is leaving out a folder that is part of the ire. If I run my application within Netbeans or as an executable jar from the command line then the application works.

              The problem is that the tool provided to embed the jre in the application bundle does not include the complete jre, all of the other folders are in the embedded jre/lib folder for the generated package. However, the jre/lib/ext is not included.
              • 4. Re: JavaFX Packager not including the jre/lib/ext folder in the resulting App
                jsmith
                Sounds like you are missing the sun jce bundle which isn't automatically included in the native packaging jre.
                This some info in igor's blog post on how to get the jce bundle in there.

                https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_cookbook_using_drop

                I'm just going to copy and past the whole relevant section here in case the blog disappears at some time in the future.
                ----------------------
                Fine tuning application bundle

                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).

                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.

                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.

                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.

                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> 
                • 5. Re: JavaFX Packager not including the jre/lib/ext folder in the resulting App
                  sselvia
                  Thanks for the link to the blog and the post. That is what I'm looking for to solve my problem.