The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Homework - Importing sun package in java
Discuss Importing sun package in java in the Java Help forum on Dev Shed. Importing sun package in java Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 29th, 2012, 07:32 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Homework - 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
|

December 29th, 2012, 10:45 AM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
Where did you see the classes described that are in the package you are having problems with?
|

December 29th, 2012, 01:25 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Quote: | 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
|

December 29th, 2012, 01:27 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
Why do you want to do that?
|

December 29th, 2012, 02:26 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Quote: | 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);
}
}
}
|

December 29th, 2012, 02:38 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
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.
|

December 29th, 2012, 03:11 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Quote: | 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?
|

December 29th, 2012, 03:23 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
It may not be possible. Did you Ask Google about the package?
|

December 29th, 2012, 03:29 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Quote: | 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???
|

December 29th, 2012, 03:31 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
I have no solution.
|

December 29th, 2012, 03:34 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 6
Time spent in forums: 1 h 16 m 12 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by NormR I have no solution. |
OK
|

December 30th, 2012, 10:02 PM
|
 |
Daniel Schildsky
|
|
Join Date: Mar 2004
Location: KL, Malaysia.
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|