<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks, Curtis, I'll take a look at the
      different strategies. Picking and choosing .jars is probably not
      so bad. Hopefully I can exclude a couple key ones and everything
      will work.<br>
      <br>
      On 12/14/2012 4:25 PM, Curtis Rueden wrote:<br>
    </div>
    <blockquote
cite="mid:CADN69ynM9zNgEeJWjniP9LXX03oTpj_eqXkDvic=AoDLMuEAUA@mail.gmail.com"
      type="cite">Hi Lee,
      <div><br>
      </div>
      <div>> <span
          style="font-family:arial,sans-serif;font-size:13px">how should
          I start ImageJ headless</span></div>
      <div><span style="font-family:arial,sans-serif;font-size:13px"><br>
        </span></div>
      <div>
        It sounds like you want a full-featured ImageJ context with all
        available services except for maybe a couple of them (the ones
        that touch AWT).<br>
      </div>
      <div><br>
      </div>
      <div>The easiest way to ensure your ImageJ context is headless is
        to exclude problematic JARs from your distribution completely.
        Specifically: do not include ij-legacy or any of the ij-ui-* UI
        implementations (e.g., ij-ui-swing).</div>
      <div><br>
      </div>
      <div>Then you can create an ImageJ context simply with "new
        imagej.ImageJ()" (note that this invocation changed a couple of
        days ago from the previous static
        "imagej.ImageJ.createContext()" but it is otherwise the same).</div>
      <div><br>
      </div>
      <div>If for some reason you need or want to include those
        problematic JARs in your classpath, you can still avoid the
        ImageJ context including them by passing an explicit list of
        services to the ImageJ constructor. Or, if you would rather
        approach it from an "exclusion" rather than "inclusion"
        standpoint, you could do something like:</div>
      <div><br>
      </div>
      <div>  final PluginIndex pluginIndex = new PluginIndex();</div>
      <div>  pluginIndex.discover();</div>
      <div><span class="">  final</span>
        List<PluginInfo<Service>> services
        = pluginIndex.getPlugins(Service.<span class="">class</span>);</div>
      <div><br>
      </div>
      <div>And then cherry-picking everything from the list that doesn't
        violate your exclusion rules.</div>
      <div><br>
      </div>
      <div>For that latter approach though, we should probably provide
        some helper routine somewhere to make this easier; if you take a
        look at ServiceHelper#findServiceClasses, you'll see the code,
        but it's currently private. We could make that a public static
        utility method for you instead. Or provide something even higher
        level.</div>
      <div><br>
      </div>
      <div>> <span
          style="font-family:arial,sans-serif;font-size:13px">how
          headless is headless?</span></div>
      <div><span style="font-family:arial,sans-serif;font-size:13px"><br>
        </span></div>
      <div><span style="font-family:arial,sans-serif;font-size:13px">Ideally,
          we want headless to truly mean no usage of AWT whatsoever.
          That said, we do violate that rule in one big place right now:
          the ThreadService. The DefaultThreadService uses
          java.awt.EventQueue to queue and invoke operations. With a
          normal JVM with java.awt.headless=true, this is unlikely to
          cause problems. But if it does for some reason, you could
          provide your own ThreadService implementation with a higher
          priority than that of DefaultThreadService, and the ImageJ
          service loader will automagically use it instead.</span></div>
      <div><span style="font-family:arial,sans-serif;font-size:13px"><br>
        </span></div>
      <div>Regards,</div>
      <div>Curtis</div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Fri, Dec 14, 2012 at 3:09 PM, Lee
          Kamentsky <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:leek@broadinstitute.org" target="_blank">leek@broadinstitute.org</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
            <br>
            Hi all,<br>
            I'm getting pretty far along with the CellProfiler
            integration and I'm<br>
            at the point where I'd like to get a headless ImageJ
            context. My first<br>
            guess was that I should call imagej.ImageJ.createContext()
            with a list<br>
            containing only the ConsoleService.  The list (see below)
            has most of<br>
            what I want (module service, command service, dataset
            service, display<br>
            service), but is missing a few others (overlay service and
            scripting<br>
            service). I've been running ImageJ with the DefaultUIService
            while<br>
            running CellProfiler with a UI and it seems to operate
            pretty smoothly -<br>
            some error messages when it can't find viewers for displays,
            but<br>
            otherwise without any apparent UI interaction.<br>
            <br>
            So my first question is how should I start ImageJ headless
            and my second<br>
            question is "how headless is headless?" (will it ever touch
            AWT? Will it<br>
            exclude the legacy layer?).<br>
            <br>
            Created service: imagej.thread.DefaultThreadService<br>
            Created service: imagej.event.DefaultEventService<br>
            Created service: imagej.plugin.DefaultPluginService<br>
            Created service: imagej.module.DefaultModuleService<br>
            Created service: imagej.command.DefaultCommandService<br>
            Created service: imagej.options.DefaultOptionsService<br>
            Created service: imagej.event.DefaultStatusService<br>
            Created service: imagej.object.DefaultObjectService<br>
            Created service: imagej.data.DefaultDatasetService<br>
            Created service: imagej.io.DefaultIOService<br>
            Created service: imagej.display.DefaultDisplayService<br>
            <br>
            <br>
            <br>
            <br>
            <br>
            _______________________________________________<br>
            ImageJ-devel mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:ImageJ-devel@imagej.net" target="_blank">ImageJ-devel@imagej.net</a><br>
            <a moz-do-not-send="true"
              href="http://imagej.net/mailman/listinfo/imagej-devel"
              target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>