4 Replies Latest reply on Oct 2, 2009 2:30 PM by 843851

    Apple Bonjour SDK and JavaFX


      Im trying to convert my existing Java desktop app into a JavaFX app.

      All is going smooth apart from the fact that for some reason the Apple Bonjour libraries cannot be found. In my existing desktop project the classes (com.apple.dnssd.*) were automatically found without me having to manually add any libraries in project properties. I have been looking about and the only major difference i can see between the project properties is that JavaFX runs off a different platform "JavaFX SDK on Java 1.6" apposed to "JDK 1.6".

      I am running windows (and osx) using Netbeans 6.7.1

      Has anyone got any suggestions for this issue?


      Edited by: mike.cann on Sep 29, 2009 2:29 PM
        • 1. Re: Apple Bonjour SDK and JavaFX

          The error im getting is:

          Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jdns_sd in java.library.path
          at java.lang.ClassLoader.loadLibrary(Unknown Source)
          at java.lang.Runtime.loadLibrary0(Unknown Source)
          at java.lang.System.loadLibrary(Unknown Source)
          at com.apple.dnssd.AppleDNSSD.<clinit>(DNSSD.java:567)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Unknown Source)
          at com.apple.dnssd.DNSSD.<clinit>(DNSSD.java:503)
          at InControl.models.BonjourProxy.setup(BonjourProxy.java:61)
          at InControl.models.BonjourProxy.<init>(BonjourProxy.java:50)
          at InControl.controllers.StartupCommand.execute(StartupCommand.java:27)
          at org.puremvc.java.core.controller.Controller.executeCommand(Controller.java:137)
          at org.puremvc.java.core.controller.Controller$1.onNotification(Controller.java:168)
          at org.puremvc.java.patterns.observer.Observer.notifyObserver(Observer.java:82)
          at org.puremvc.java.patterns.observer.Observers.notifyObservers(Observers.java:94)
          at org.puremvc.java.core.view.View.notifyObservers(View.java:119)
          at org.puremvc.java.patterns.facade.Facade.notifyObservers(Facade.java:382)
          at InControl.ApplicationFacade.startup(ApplicationFacade.java:57)
          at InControl.InControlJavaApp.startup(InControlJavaApp.java:22)
          at org.jdesktop.application.Application$1.run(Application.java:171)
          at java.awt.event.InvocationEvent.dispatch(Unknown Source)
          at java.awt.EventQueue.dispatchEvent(Unknown Source)
          at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.run(Unknown Source)

          I have had a look inside the source for Apple's Bonjour in the DNSSD.java class and its falling over at this part:

          class     AppleDNSSD extends DNSSD
                    System.loadLibrary( "jdns_sd");
                    int          libInitResult = InitLibrary( 1);

                    if ( libInitResult != DNSSDException.NO_ERROR)
                         throw new InternalError( "cannot instantiate DNSSD: " + new AppleDNSSDException( libInitResult).getMessage());

          So it looks like they are using JNI to load a system library, but why this works fine for the JDK and not for JavaFX i dont know...

          Im sure its just something to do with the way my project is setup, anyone?
          • 2. Re: Apple Bonjour SDK and JavaFX
            So none know why System.loadLibrary( "jdns_sd"); is falling over on JavaFX? But works in a regular JDK project?
            • 3. Re: Apple Bonjour SDK and JavaFX
              I guess you don't have much answer because nobody (?) use Apple Bonjour... :-) Not even sure what it is exactly (agenda synchronization?).

              Anyway, that's right, it is probably more a problem of Java than something else.
              println(System.getProperty("java.library.path").replaceAll(System.getProperty("path.separator"), '\n'));
              On my system, it shows only {color:#8000A0}*C:\Java\javafx-sdk1.2.1\bin\..\lib\desktop*{color} while on a Java program, it shows lots more, including Windows system dirs and such stuff in the PATH.
              So perhaps you have to add a {color:#8000A0}*-Djava.library.path=X:/location/of/the/dll*{color} to the command line/start parameters of your JavaFX application.
              If you have done that already, not sure what else to advice.
              • 4. Re: Apple Bonjour SDK and JavaFX
                Unfortunately I have already tried doing that to no avail.

                Apple Bonjour is a Zero-config service for networking, allowing me to see other services on a local network.

                For anyone that stumbles accross this thread, I have decided to go with a pure-java alternative JMDNS instead, and this now works.