I want to calculate the memory usage of an object (Treap in a package with name TreapDS)that I created. I found that I need to follow of these steps based on this page. I always use Eclipse so I am not familiar with running Java code with commands. I asked question how can I build jar files based on that page in this page but I did not receive any answer. This is the hierarchy of my packages:
Indexing
| --- bin
|---- MemoryUsage
| -- mainfest.MF
| -- Myagent
| --- src
|--- treapDS
| |--- Treap
|---- MemoryUsage
| -- TestCase
| -- Myagent
I can create a jar file based on running the command in this address
Indexing/bin$ jar -cmf MemoryUsage/manifest.MF agent.jar MemoryUsage/MyAgent.class
It create agent.jar in bin folder and when I extract this jar file in consist of two folders MemoryUsage which contains Myagent.class and folder META-INF which contains MANIFEST.MF
but when I run the following command I got the exception and I do not know how to solve it by mentioning the address of the Treap. Is there any way to do this with eclipse?
/Indexing/bin$ java -javaagent:agent.jar -cp MemoryUsage/TestCase
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NoClassDefFoundError: treapDS/Treap
at MemoryUsage.MyAgent.premain(MyAgent.java:9)
... 6 more
Caused by: java.lang.ClassNotFoundException: treapDS.Treap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
FATAL ERROR in native method: processing of -javaagent failed
Aborted (core dumped)