Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Environment issue with Bonjour API

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Environment issue with Bonjour API

    Hi all,

    I've been having one of those really annoying problems that you just KNOW must be some damn simple setting somewhere and can't for the life of you figure it out.

    I wanted to write a simple java program to use Apple's DNS Service Discovery APIs to broadcast a service on a wifi network (for the Bonjour zero-configuration protocol). The code itself is very simple (and runs on my friend's computer).

    However, when I run this code I get the following runtime exception:
    Exception in thread "main" 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:596)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Unknown Source)
    	at com.apple.dnssd.DNSSD.<clinit>(DNSSD.java:529)
    	at server.ServiceAnnouncer.registerService(ServiceAnnouncer.java:22)
    	at server.Main.main(Main.java:17)

    Now I must say that there was some fishy things going on when I was installing the Bonjour SDK. First, it didn't install. I forget what the error message was, but it prompted me to go to Control Panel and uninstall 3 items marked "Java Update blah blah". It installed after that, placing a bunch of files in C:\Program Files\Bonjour SDK\ . However, the files seemed to be different than those on my friend's computer. Namely, I couldn't find a dns_sd.jar file anywhere. So I got that file from my friend, placed it in a folder on the desktop, and added to the project.
    In my desperate attempts to fix this, I also added any directory with Bonjour SDK files to the PATH variable and edited the eclipse ini file to run the java vm with the -Djava.library.path option, again adding those directories to the path. All to no avail.

    So if anyone knows how I can fix this situation, I would highly appreciate it. Alternatively, if anyone knows how I can purge all java related files, settings, registry values, etc. (WHATEVER THERE MAY BE) out of my system in order to do a clean install with all the files in the right places, that would be good too.

    Cheers,
    DR


  2. #2
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Wink Re: Environment issue with Bonjour API

    Hey DarkRoast,

    Seems like the issue is that you are using some native methods in your program and the native libraries are missing from the path.

    Here is what java docs says about UnsatisfiedLinkError : "Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native"

    Here is one link from sun about the native method usages and properties to be set: Sun Native Methods

    This user encountered the same problem and resolved it on his own from Apple-Discussions

    In case if you want to print what your java library path is, you can do it using following:
    public void getSystemProperty() {
    String path = System.getProperty("java.library.path");
    System.out.println(path);
    }
    Hope that helps you to sort out the issue.

    Goldest
    Java Is A Funny Language... Really!

    Sun: Java Coding Conventions

    Click on THANKS if you like the solution provided.
    Click on Star if you are really impressed with the solution.

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Environment issue with Bonjour API

    Thanks, Goldest.

    I hadn't seen the Java documentation on native methods, but I had found that thread on the Apple forums. That guy fixed the issue on a *nix box using the make files of the SDK. On Windows, that doesn't help me much.

    However, I did get the program running on another way older PC running a fresh install of WinXP and the latest JRE, so that keeps me happy for now.

Similar Threads

  1. Replies: 0
    Last Post: November 13th, 2010, 04:08 PM
  2. Graphic Environment Abstract Methods
    By striko_514 in forum Java Theory & Questions
    Replies: 2
    Last Post: July 5th, 2010, 01:01 AM
  3. Replies: 1
    Last Post: March 23rd, 2010, 02:29 AM
  4. Bonjour
    By larde in forum Member Introductions
    Replies: 3
    Last Post: January 4th, 2010, 12:57 PM
  5. Replies: 1
    Last Post: July 10th, 2008, 05:03 AM