anchor.diff:      end.
   
   log_first_lines_from_port(Module, Port) ->
  -    log_port_lines(Module, Port,3).
  -
  -log_port_lines(_, _, 0) -> ok;
  -log_port_lines(M, Port, N) ->
  -    receive
  +    Pid = log_port_lines(Module, Port, undefined, 1),
  +    log_port_lines(Module, Port, undefined, 2),
  +    Pid.
  +
  +log_port_lines(_, _, R, 0) -> R;
  +log_port_lines(M, Port, _, N) ->
  +    R = receive
           {Port, {data, {_Type, Data}}} ->
  -            lager:info("[gen_java][~p] startup: ~p", [M, Data])
  +            lager:info("[gen_java][~p] startup: ~p", [M, Data]),
  +            Data
       after
           20000 ->
  -            lager:info("[gen_java] didn't output anything on startup")
  +            lager:info("[gen_java] didn't output anything on startup"),
  +            undefined
       end,
  -    log_port_lines(M, Port, N-1).
  +    log_port_lines(M, Port, R, N-1).
  
positive.code:         ok ->
              rpc:call(Nodename, erlang, link, [self()]),
              erlang:monitor_node(Nodename, true),
              init_callback( State#gen_java_state{ port = Port });
          timeout ->
              {stop, timeout}
      end.
  
negative.code:     Jar = proplists:get_value(jar, Config),
      Threads = proplists:get_value(thread_count, Config, ?DEFAULT_THREAD_COUNT),
      Port = start_jar(Nodename, Jar, Module, Threads),
      Pid = log_first_lines_from_port(Module, Port),
      lager:info("[gen_java][~p] OS Pid: ~p", [Module, Pid]),
      %% Wait at most ten seconds for the node to come up
      case wait_until(
                      fun() ->
  