I mean to collect the function calling, memory and cpu usage information of a running java application. Are there some existing open-source tools to achieve this?
Usually a profiler you attach to a running JVM does the trick if you want to look at these parameters.
There are a lot of different ones you can use.
VisualVM, Yourkit, JProfiler, etc.
Netbeans comes with a profiler built in, for eclipse and Intellij IDEA you can plug them in. Most profilers also give you the option to scan your running processes for JVMs and hook up to these aswell.
Thanks Davy! By the way, can I user these tools, such as VisualVM and Yourkit, to export the collect data for further analysis. Or can I do some adaptation work on these existing tools to fit my needs.
This is usually shown in graphs and drilldown menus that you can export. You can also take heapdumps and snapshots at times that you find interesting to do more in depth research after running the program in case it needs a lot of user input.
I would suggest giving one or a couple a test spin on a small program or something straightforward but with an acceptable running time to just explore for 10-15 minutes and choose the one that suits you best