Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 38 of 38

Thread: cannot find symbol:getSystemCpuLoad()

  1. #26
    Junior Member
    Join Date
    Jul 2014
    Location
    Canada
    Posts
    25
    My Mood
    Bored
    Thanks
    0
    Thanked 5 Times in 4 Posts

    Default Re: Empty dialog

    Quote Originally Posted by hooshdar3 View Post
    It is just that My professor wanted me to write a java code, and he doesn't tell us what to do
    Quote Originally Posted by hooshdar3 View Post
    I have studied some examples, but believe me or not, I have no teacher. Never had any teacher.
    Well I'm confused. I assume you mean to say that you haven't had a formal education in Java, but then I would argue that a formal education isn't necessary as long as you have the drive to learn the language yourself. Greg's point, as far as I can tell, is that without understanding the fundamentals of Java and programming in general, you're going to run into some very basic misunderstandings and issues.

    As for the last question that you asked, what are the checkboxes supposed to do when they are ticked? What is the desired output of the program? It's difficult to pin down how a program is misbehaving without knowing how it is meant to behave in the first place.

  2. #27
    Member
    Join Date
    Mar 2014
    Posts
    70
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: Empty dialog

    Quote Originally Posted by DuncanS View Post
    Well I'm confused. I assume you mean to say that you haven't had a formal education in Java, but then I would argue that a formal education isn't necessary as long as you have the drive to learn the language yourself. Greg's point, as far as I can tell, is that without understanding the fundamentals of Java and programming in general, you're going to run into some very basic misunderstandings and issues.

    As for the last question that you asked, what are the checkboxes supposed to do when they are ticked? What is the desired output of the program? It's difficult to pin down how a program is misbehaving without knowing how it is meant to behave in the first place.
    The check boxes will read "OS version", "CPU architecture", etc , according to which some boolean variables are set, which help to decide which fields of a stored object in a queue will be retrieved.
    But the error is exactly on the getSystemCpuLoad() line: I commented it out nd the compiler error disp\appeared

  3. #28
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Okay, let's get back on topic . . .

    Post your latest code that demonstrates the problem - two JDialogs with one button each, some check boxes if needed, describe the problem or your confusion, and ask the questions needed to resolve any problems and move on. Focus on understanding and fixing one thing at a time.

  4. #29
    Member
    Join Date
    Mar 2014
    Posts
    70
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Quote Originally Posted by GregBrannon View Post
    Okay, let's get back on topic . . .

    Post your latest code that demonstrates the problem - two JDialogs with one button each, some check boxes if needed, describe the problem or your confusion, and ask the questions needed to resolve any problems and move on. Focus on understanding and fixing one thing at a time.
    My latest, shortened code is:
    import java.io.*;
    import java.util.*;
    import java.util.concurrent.TimeUnit;
    import com.sun.management.OperatingSystemMXBean;
    import java.lang.management.ManagementFactory;
    import java.lang.System;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
     
        public class SysinfoHooshi implements ActionListener{
    		int k;
     
    		class Info{			
    			public String name;
    			public String version;
    			public String arch;
    			public double ramUtil;
    			public double CPUUtil;
    		};
     
        JTextField  tf = new JTextField("");
        JTextField  tf2 = new JTextField("");
        JDialog dialog = new  JDialog();	
        JButton button = new JButton("OK");
     
        /****************Query dialog variables*******************/
        JDialog queryDialog = new  JDialog();	
        JButton queryButton = new JButton("OK");
        JCheckBox chkCPUUtil = new JCheckBox("CPU utilization");
        JCheckBox chkRAMUtil = new JCheckBox("RAM utilization");
        JCheckBox chkVersion = new JCheckBox("Version of the OS");
        JCheckBox chkArch = new JCheckBox("Processor architecture");
        JCheckBox chkName = new JCheckBox("Operating system name");
        boolean nameChecked, versionChecked, archChecked, CPUChecked, RAMChecked;
        /*********************************************************/
     
    	public  void simulate()throws Exception{
     
    		this.showDialog();
    		showQueryDialog();
     
    	}//end simulate()
     
    	public void showDialog()
    	{
    		dialog.setModal(true);
    		dialog.setSize(400, 150);
     
    		dialog.setTitle("Input dialog");
     
    		Container pane = dialog.getContentPane();
    		pane.setLayout(null);
     
     
    		JLabel l1 = new JLabel("simtime(min)");
    		pane.add(l1);
    		l1.setBounds(10, 10, 100, 10);
     
     
    		pane.add( tf);
    		tf.setBounds(110,10, 40, 15);
     
    		JLabel l2 = new JLabel("interval(sec)") ;
    		pane.add(l2);
    		l2.setBounds(10, 50, 100, 10);
     
     
    		pane.add( tf2);
    		tf2.setBounds(110,50, 40, 15);
     
     
    		pane.add(button);
    		button.addActionListener(this);
    		button.setBounds(100,100,80,30);
    		dialog.setVisible(true);
    	}
     
    	 public void actionPerformed(ActionEvent e) {
    		 if(e.getSource() == button)
    		    dialog.setVisible(false);
    		 if(e.getSource() == queryButton)
    		    queryDialog.setVisible(false);
    	}
     
    	public void showQueryDialog()
    	{
    		queryDialog.setModal(true);
    		queryDialog.setSize(400, 150);
     
    		queryDialog.setTitle("Query dialog");
     
    		JPanel queryPane = new  JPanel();
    		queryPane.setLayout(new FlowLayout());
    		queryPane.add(chkName);
    		queryPane.add(chkVersion);
    		queryPane.add(chkArch);	
    		queryPane.add(queryButton);
    		queryDialog.add(queryPane);	
    		queryDialog.setVisible(true);
     
     
    				chkName.addItemListener (new ItemListener() {
    			public void itemStateChanged( ItemEvent e)
    			{nameChecked=e.getStateChange()==1 ? true : false;}
    		});
     
    		chkVersion.addItemListener (new ItemListener() {
    			public void itemStateChanged( ItemEvent e)
    			{ versionChecked=e.getStateChange()==ItemEvent.SELECTED ? true : false;}
    		});
     
    		chkArch.addItemListener (new ItemListener() {
    			public void itemStateChanged( ItemEvent e)
    			{ archChecked=e.getStateChange()==1 ? true : false;}
    		});
     
    		chkCPUUtil.addItemListener (new ItemListener() {
    			public void itemStateChanged( ItemEvent e)
    			{ CPUChecked=e.getStateChange()== 1 ? true :false;}
    		});
     
    		chkRAMUtil.addItemListener (new ItemListener() {
    			public void itemStateChanged( ItemEvent e)
    			{ RAMChecked = e.getStateChange()==1 ? true :false;}
    		});
     
    		/*queryButton.addActionListener(this);
    	}
     
     
    	public static void main(String args[]) throws Exception{	
    	SysinfoHooshi o = new SysinfoHooshi();
    	o.simulate();
     
     
    	} // end main
       }// end class
    Both the buttons are supposed to hide their respective parent dialogues, but the second one doesn't.

  5. #30
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Because the line where you add your action listener to the button is commented out.
    /*queryButton.addActionListener(this);
    You should really learn how to debug your code. Add System.out.println(...); statements to your methods to find out what is going on. This will help you to find errors in your code.

    By the way, you should also read up on OOP design and start using separate classes for your different dialogs.

  6. #31
    Member
    Join Date
    Mar 2014
    Posts
    70
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Quote Originally Posted by Cornix View Post
    Because the line where you add your action listener to the button is commented out.
    /*queryButton.addActionListener(this);
    You should really learn how to debug your code. Add System.out.println(...); statements to your methods to find out what is going on. This will help you to find errors in your code.

    By the way, you should also read up on OOP design and start using separate classes for your different dialogs.
    Why should I use one class per Dialog?
    What would be System.out.println() good for? I am seeing that the first button works when clicked, while the second doesn't (they should both close the dialog of which they are part

    --- Update ---

    Quote Originally Posted by GregBrannon View Post
    You mentioned a professor earlier, and someone/something is requiring you to use OpenJDK. If you and your professor aren't connecting, then all the more reason to STUDY.
    Our professor teaches us 'Grid Computing', not specifically 'Java programming'. But he wants us to write our programs in Java.
    He is unwiling to help us in prigramming, saying that we are MSc students.

    I should turn in the code sooner. in about 70 hours.
    Last edited by hooshdar3; July 18th, 2014 at 12:53 PM.

  7. #32
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Quote Originally Posted by hooshdar3 View Post
    Why should I use one class per Dialog?
    To make your code easier to read. Putting all of your code into one huge class is very bad practice.
    Quote Originally Posted by hooshdar3 View Post
    What would be System.out.println() good for? I am seeing that the first button works when clicked, while the second doesn't (they should both close the dialog of which they are part
    It would help you understand why your code does not work by showing you which parts work, and which parts dont.
    You could add code to see whether the button is pressed but the condition is wrong. Or if an action listener was added in the first place.

  8. #33
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Why should I use one class per Dialog?
    What would be System.out.println() good for? I am seeing that the first button works when clicked, while the second doesn't (they should both close the dialog of which they are part
    The first question was answered in the suggestion. Don't be difficult.

    There are many ways to use println() to troubleshoot code. The most common are to track or trace the execution of code and to check variable values. If you see no value in its use, don't use it. Yes, you can see your code isn't working by observing the results, but you have no idea why. That's why you're here, and that's what others are trying to help you with.

    Though I don't really know what "Grid Computing" is or what it has to do with programming, its concept seems consistent with OOP. That's another reason to use multiple classes rather than writing all of your code in one.

    If you prefer to challenge the advice given by others rather than attempt to learn from it, this thread will be closed and you will be restricted from posting for a period of time.

  9. #34
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Also learn what breakpoints in a debugger are used for. You can step
    in and out of the code. Cornix was valid when he/she mentioned about
    using println statements in the code. Even if they do not actually help in
    the actual output - they do help in debugging processes.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  10. #35
    Member
    Join Date
    Mar 2014
    Posts
    70
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Quote Originally Posted by GregBrannon View Post
    The first question was answered in the suggestion. Don't be difficult.

    There are many ways to use println() to troubleshoot code. The most common are to track or trace the execution of code and to check variable values. If you see no value in its use, don't use it. Yes, you can see your code isn't working by observing the results, but you have no idea why. That's why you're here, and that's what others are trying to help you with.

    Though I don't really know what "Grid Computing" is or what it has to do with programming, its concept seems consistent with OOP. That's another reason to use multiple classes rather than writing all of your code in one.

    If you prefer to challenge the advice given by others rather than attempt to learn from it, this thread will be closed and you will be restricted from posting for a period of time.
    Grid computing has nothing to do with OOP.Its a form of distributed computing.

    --- Update ---

    Quote Originally Posted by Cornix View Post
    It would help you understand why your code does not work by showing you which parts work, and which parts dont.
    You could add code to see whether the button is pressed but the condition is wrong. Or if an action listener was added in the first place.
    There is just one actionPerformed() method, so the problem is fairly pin-pointed

  11. #36
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    In that case - why is he not splitting the classes into Grid Computing and Java Programming
    principles? Seems rather foolish that he is expecting a student to know the ins and outs of Java
    whist learning a totally alien concept.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  12. #37
    Member
    Join Date
    Mar 2014
    Posts
    70
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Quote Originally Posted by Ada Lovelace View Post
    In that case - why is he not splitting the classes into Grid Computing and Java Programming
    principles? Seems rather foolish that he is expecting a student to know the ins and outs of Java
    whist learning a totally alien concept.

    Wishes Ada xx
    Java programming is a part of their undergraduate program, while we are graduate students.

  13. #38
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cannot find symbol:getSystemCpuLoad()

    Thread closed. Not making progress and OP is challenging rather than cooperating.

  14. The Following User Says Thank You to GregBrannon For This Useful Post:

    KevinWorkman (July 21st, 2014)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. cannot find symbol
    By lungelo in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2013, 05:06 AM
  2. [SOLVED] Cannot Find Symbol
    By ChicoTheMan94 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 25th, 2012, 02:46 PM
  3. Cannot find symbol
    By BadgerWatch in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 6th, 2011, 11:25 PM
  4. Cannot find Symbol?
    By defmetalhead in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 5th, 2011, 08:48 AM
  5. Cannot find symbol?
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2010, 10:02 PM