Note that there are some explanatory texts on larger screens.

plurals
  1. POnon static method cannot be referenced from static context - JAVA
    text
    copied!<p>i am trying to pass the value t from one class to another, but before i even run the program i get <code>non static method cannot be referenced from static context</code> from this line of code :</p> <pre><code>t = (PrinterSettings.getT() * 60); </code></pre> <p>i am trying to get the value t from this code :</p> <pre><code>public int t = 1; //defualt value for amount of mintues in the future the job should wait untill sent public int getT() { return (t); } public void setT(int t) { this.t = t; } </code></pre> <p>what have i done wrong ? and how can i get t </p> <p>EDIT :</p> <p>Whole of my code where i get t from </p> <pre><code> public int t = 1; //defualt value for amount of seconds in the future the job should wait untill sent public int getT() { return (t); } public void setT(int t) { this.t = t; } </code></pre> <p>and this is the class that i am using that calls t from the above class to use:</p> <pre><code>public class DealyTillPrint { public int t; public String CompletefileName; private String printerindx; private static int s; private static int x; public static int SecondsTillRelase; public void countDown() { System.out.println("Countdown called"); s = 1; // interval t = ((new PrinterSettings().getT()) * 60); //(PrinterSettings.SecondsTillRelase); // number of seconds System.out.println("t is : " + t); while (t &gt; 0) { System.out.println("Printing in : " + t); try { Thread.sleep(s * 1000); } catch (Exception e) { } t--; } </code></pre> <p>and here is where i set <code>t</code> using a spinner </p> <pre><code>&lt;p:spinner min="1" max="1000" value="#{printerSettings.t}" size ="1"&gt; &lt;p:ajax update="NewTime"/&gt; &lt;/p:spinner&gt; </code></pre>
 

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