Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:32:29+00:00 2026-06-18T15:32:29+00:00

i am trying to pass the value t from one class to another, but

  • 0

i am trying to pass the value t from one class to another, but before i even run the program i get non static method cannot be referenced from static context from this line of code :

t = (PrinterSettings.getT() * 60);

i am trying to get the value t from this 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;
         } 

what have i done wrong ? and how can i get t

EDIT :

Whole of my code where i get t from

         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;
    }

and this is the class that i am using that calls t from the above class to use:

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 > 0) {
            System.out.println("Printing in : " + t);
            try {
                Thread.sleep(s * 1000);
            } catch (Exception e) {
            }
            t--;
        }

and here is where i set t using a spinner

<p:spinner min="1" max="1000" value="#{printerSettings.t}"  size ="1">
                    <p:ajax update="NewTime"/>
                </p:spinner>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:32:31+00:00Added an answer on June 18, 2026 at 3:32 pm

    You can choose to do 1 of 2 things:

    1) Make everything in your PrinterSettings file static (and make PrinterSettings static as well):

    public static int t = 1; 
    
    public static int getT() {
                return (t);
            }
    
     public static void setT(int t) {
                this.t = t;
             } 
    

    2) Don’t change PrinterSettings, and just do this for your code:

    //Put this somewhere at the beginning of your code:
    PrinterSettings printerSettings = new PrinterSettings();
    
    //Now have some code, which will include setT() at some point
    
    //Then do this:
    t = (printerSettings.getT() * 60);
    

    In my opinion the latter would be more preferable.

    EDIT: The edit that I just made is because if you don’t keep a hold on the PrinterSettings variable that you were using, new-ing one up will have t be 1 in that new PrinterSettings object. Instead, make sure that you’re instantiating an object of PrinterSettings at the beginning of your program, and just use that one the whole way through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to pass a string value from one method into another.
I can not pass one value from one class to another, when i try,
I am trying to pass a long value from intent of one class to
I'm trying to pass a variable from one function to another, but the var
I'm trying to pass a null value from a RenderAction to another view. But
I'm trying to pass a String array from one activity to another but when
I am trying to pass a value from php to javascript. I understand one
I am trying to get the value user selected from search prompt and pass
I'm trying to pass value by using EL expression in get request parameter, but
I am trying pass class as value in hashmap. I need to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.