aspose file tools*
The moose likes Java in General and the fly likes java program problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java program problem" Watch "java program problem" New topic
Author

java program problem

gangs sandrani
Greenhorn

Joined: Jul 06, 2011
Posts: 9
hai frnds, i am new to java development.... i just wanna to develop a program to print the physical memory occupied and no-of cpu cycles taken by an application in java....can any help me out which java classes to be used....
Wim Vanni
Ranch Hand

Joined: Apr 06, 2011
Posts: 96

Welcome to the Ranch!

Have you looked into any library yourself? In most cases a simple Google search will turn up many hits if you specify good keywords to search for ..

Cheers,
Wim
gangs sandrani
Greenhorn

Joined: Jul 06, 2011
Posts: 9
thank you wim, but i could not find any libraries/classes in google....can you give me a hint to start...
Wim Vanni
Ranch Hand

Joined: Apr 06, 2011
Posts: 96

Try using the keywords 'java profiler' (or profiling).

Wim
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Welcome to the Ranch, gangs sandrani.

Writing a Java profiler, or something that can count the number of CPU cycles and exact memory usage of a Java program, is a quite advanced subject. In Java, the JVM normally shields you from low-level things like those.

The JDK comes with a nice application, VisualVM, that can analyze memory usage, threads, CPU usage etc. of Java processes. You can start it by typing jvisualvm in a command prompt window.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
gangs sandrani
Greenhorn

Joined: Jul 06, 2011
Posts: 9
I want to get process related information for an application running in task manager...

ImageName: firefox.exe
PID: 1234
CPU: 03%
Mem Usage: 22532K
Threads: 12


can any body tell me what all the methods(classes) to be used to get these information
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Things like that are unfortunately not easy to get at in Java, because they are low-level, operating system specific things. There are no classes in the standard Java API that can easily give you that information for arbitrary programs running on your computer.

If you really want to do it, you would have to write some native code (in for example C or C++) that does operating system specific calls to get the information; you could call your native code via JNI (Java Native Interface).
gangs sandrani
Greenhorn

Joined: Jul 06, 2011
Posts: 9
Thank you Jesper de Jong ,
can you post me some example of native code....via JNI (Java Native Interface).
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Don't double post the same question. Your other thread has been locked.


luck, db
There are no new questions, but there may be new answers.
gangs sandrani
Greenhorn

Joined: Jul 06, 2011
Posts: 9
ok dude
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java program problem