#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Exclamation Importing sun package in java


    Hello there,
    I am working on some multitasking sort of application.
    I need to keep log of all java processes being running currently. For that purpose I found that I need to import sun.jvmstat.monitor.*;
    but I am getting error on this import i.e.
    import sun.jvmstat cannot be resolved

    I am extremely new to java so i dont know much about jre paths etc. please provide an easy step by step solution to this problem. I am using eclipse IDE.

    ps. I also tried to follow a solution on stackoverflow website
    on how-do-i-include-jvmstat
    this directed me to download j2eesdk-1_4_03-windows
    I downloaded and installed this but couldnt help me in my problem

    I would appreciate your help.
    Regards
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Where did you see the classes described that are in the package you are having problems with?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by NormR
    Where did you see the classes described that are in the package you are having problems with?
    sorry i didnt get your question..
    I am having error on import sun.jvmstat
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    import sun.jvmstat
    Why do you want to do that?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by NormR
    Why do you want to do that?
    I want to run this code:

    import java.util.*;
    import sun.jvmstat.monitor.*;
    public class ListJavaProcess {

    public static void main(String[] args) throws Exception {

    /* Checking for local Host, one can do for remote machine as well */

    MonitoredHost local = MonitoredHost.getMonitoredHost("localhost");

    /* Take all active VM's on Host, LocalHost here */

    Set vmlist = new HashSet(local.activeVms());

    for (Object id : vmlist) {

    /* 1234 - Specifies the Java Virtual Machine identified by lvmid 1234 on an unnamed host.

    This string is transformed into the absolute form //1234, which must be resolved against

    a HostIdentifier. */

    MonitoredVm vm = local.getMonitoredVm(new VmIdentifier("//" + id));

    /* take care of class file and jar file both */

    String processname = MonitoredVmUtil.mainClass(vm, true);

    System.out.println(id + " ------> " + processname);

    }

    }
    }
  10. #6
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Where did you get the code? Did the author of that code say where the classes are that are needed?

    Did you google on the package name to see details on the history of that package?
    It's at least 6 years old and out of date.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by NormR
    Where did you get the code? Did the author of that code say where the classes are that are needed?

    Did you google on the package name to see details on the history of that package?
    It's at least 6 years old and out of date.

    Actualy I searched on how to keep the log of all java process being running and I also need to display them. So, all the links which I got includes this same package. i.e.
    Import sun.jvmstat

    now what to use instead?
  14. #8
  15. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    It may not be possible. Did you Ask Google about the package?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by NormR
    It may not be possible. Did you Ask Google about the package?
    yes i did. would you give me some solution now???
  18. #10
  19. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    I have no solution.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by NormR
    I have no solution.
    OK
  22. #12
  23. Daniel Schildsky
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2004
    Location
    KL, Malaysia.
    Posts
    1,542
    Rep Power
    1621

    Monitoring JVM processes


    I am not sure if it is possible to log all JVM processes, but for displaying and monitoring them, I have found this from google:
    JConsole

    JConsole displays a graphical UI to present various aspects of a particular or some processes or all JVM processes currently running. Try it out and see if it satisfies what you are trying to achieve.

    You need to write your own codes only if it still can't fulfill your needs.
    When the programming world turns decent, the real world will turn upside down.

IMN logo majestic logo threadwatch logo seochat tools logo