[Tinyos-help] Compiling Errors!

Paul Stickney pstickne at gmail.com
Sat May 3 20:47:17 PDT 2008


> I still get the following error:
>
> XListen.java:69: non-static method printPacket(java.io.PrintStream,byte[])
> canno
> t be referenced from a static context
>
>  XDump.printPacket(System.out, packet);
>  ^
>
> How can I resolve it?

I would guess XDump is a class:
you can only invoke the "non-static" printPacket(...) on an object
instantiated from the class.

public class A {
  public static void foo() {System.out.println("foo");}
  public void bar() {System.out.println("bar");}
}

// elsewhwere
A.foo()  // okay, foo is static, has no corresponding instantiated object
A.bar()  // bad! bar is not static! (you can't invoke it directly on a class)
(new A()).bar() // okay, you are calling bar() on an instantiated object


Paul


More information about the Tinyos-help mailing list