Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem investigating JmDNS3.4.1 jar
    text
    copied!<p>I'm newbie here. I'm dealing with my first program using osgi bundles and JmDNS. After adding JmDNS 3.4.1 jar to my project, I'm testing the following basic code:</p> <p>My Activator:</p> <pre><code>package test.discoverservice; import java.io.IOException; import test.DiscoverServices; import javax.jmdns.JmDNS; import javax.jmdns.ServiceTypeListener; import org.equinoxosgi.jmdns.dev.discoverservice.DiscoverServices.SampleListener; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class JmdnsActivator implements BundleActivator { public void start(BundleContext context) throws Exception { System.out.println("Launching"); try { System.out.println("step 1"); final JmDNS jmdns = JmDNS.create(); System.out.println("step 2"); jmdns.addServiceListener("_http._tcp.local.", new SampleListener()); // jmdns.close(); // System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } } public void stop(BundleContext context) throws Exception { System.out.println("Terminating"); } } </code></pre> <p>and here is the bundle:</p> <pre><code>package test.discoverservice; import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceListener; public class DiscoverServices { static class SampleListener implements ServiceListener { @Override public void serviceAdded(ServiceEvent event) { System.out.println("Service added : " + event.getName() + "." + event.getType()); } @Override public void serviceRemoved(ServiceEvent event) { System.out.println("Service removed : " + event.getName() + "." + event.getType()); } @Override public void serviceResolved(ServiceEvent event) { System.out.println("Service resolved: " + event.getInfo()); } } } </code></pre> <p>when I run the code, I get :</p> <pre><code>osgi&gt; Launching step 1 </code></pre> <p>and then it stops, so I guess there is a probelm with the creation of the JmDNS instance.. Any idea please?</p> <p>Note that if I don't use a bundle with an activator (simple program with main) everything works properly </p> <pre><code>import java.io.IOException; import javax.jmdns.JmDNS; import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceTypeListener; public class DiscoverServiceTypes { static class SampleListener implements ServiceTypeListener { @Override public void serviceTypeAdded(ServiceEvent event) { System.out.println("Service type added: " + event.getType()); } public void subTypeForServiceTypeAdded(ServiceEvent event) { System.out.println("SubType for service type added: " + event.getType()); } } public static void main(String[] args) { try { JmDNS jmdns = JmDNS.create(); System.out.println("JmDNS created !!"); jmdns.addServiceTypeListener(new SampleListener()); // jmdns.close(); // System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>PS: I'm running it on Windows</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload