Running the heapTracker example

Hi there

I am trying to run the heapTracker example that is in the demo/jvmti directory, and I am having problems with it. When I try to run it with what it says in the readme file (java -Xbootclasspath/a:heapTracker.jar), I get the following error message:

ERROR: JNI: Cannot find heapTracker with FindClass

It seems like a small problem, but it is making me go crazy! Has anyone else ever encountered this before?

Cheers

Sajid

[465 byte] By [SajidTendulkara] at [2007-10-3 9:38:55]
# 1
Which version is this? You should just need to put -agentlib:heapTracker on the command line and it will add heapTracker.jar to the boot class path itself. Also, the class name is HeapTracker and it's interesting that your version is looking for "heapTracker".
alan.batemana at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Hi

Thank you for your reply, I tried your suggestion, and it gave the following:

D:\My Documents\ >java -agentlib:HeapTracker MyClass

ERROR: JNI: Cannot find HeapTracker with FindClass

The version of java I am using is as follows:

D:\My Documents\ >java -version

java version "1.5.0_08"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)

Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

I tried adding heapTracker.jar to the classpath myself, but it did not make any difference.

Thank you for your time

Sajid

SajidTendulkara at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
Worked for me with 5.0u8:java -Xbootclasspath/a:heapTracker.jar -agentpath:lib\heapTracker.dll ...
alan.batemana at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

Hi

Yeah, I managed to get it to work?I move the jar file into the same directory as the dll抯卻eems a bit strange, but it worked.

A problem I am going to try and make some changes to the heaptracker, but I can not get it to compile, the errors I have listed below. It looks like I am missing a library or something, but I am not sure which. Has anyone else ever encountered a problem like this?

error LNK2019: unresolved external symbol _fatal_error referenced in function _checkJvmtiErrorheapTracker.obj

error LNK2019: unresolved external symbol _java_crw_demo@76 referenced in function _cbClassFileLoadHook@40heapTracker.obj

error LNK2019: unresolved external symbol _java_crw_demo_classname@12 referenced in function _cbClassFileLoadHook@40heapTracker.obj

error LNK2019: unresolved external symbol _stdout_message referenced in function _parse_agent_optionsheapTracker.obj

error LNK2019: unresolved external symbol _get_token referenced in function _parse_agent_optionsheapTracker.obj

Any help would be very much appreciated.

Thank You

Sajid

SajidTendulkara at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5
You seem to be missing the java_crw_demo when you are linking. There is a sample make file in the directory if that helps.
alan.batemana at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6

Hi, thanks for the advice, I tried it out, and it did improve the situation.

It now gives me 3 errors (down from 5), I have found that the unresolved references come from agent_util.h:

heapTracker.obj : error LNK2019: unresolved external symbol fatal_error referenc

ed in function checkJvmtiError

heapTracker.obj : error LNK2019: unresolved external symbol stdout_message refer

enced in function parse_agent_options

heapTracker.obj : error LNK2019: unresolved external symbol get_token referenced

in function parse_agent_options

heapTracker.dll : fatal error LNK1120: 3 unresolved externals

make: *** [heapTracker.dll] Error 1120

I am trying to link it to the agent_util.obj, but this is causing problems. I use the following command to make the obj file:

cl -I"c:\Program Files\java\jdk1.5.0_08\include" -I"c:\Program Files\java\jdk1.5.0_08\include\win32" -I"C:\Program Files\Microsoft Visual Studio 8\VC\include" /Foagent_util.obj /c agent_util.c

Then, when I try to make the heapTracker, it gave the following message:

agent_util.obj : fatal error LNK1112: module machine type 'X86' conflicts with t

arget machine type 'x64'

make: *** [heapTracker.dll] Error 1112

That is a very strange looking message, I tried looking for help but could not find anything.

I am doing something wrong when I try to create the agent_util.obj?

SajidTendulkara at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7

Hi, the compilation and running of unaltered code is quite simple - just cross check with the below -

if your java files are in directory 1/* ( 1/something.java , 1/something.c) then the directory in which it is located in must also have agent_util directory.

ie,

ls parent/ gives

drw-rw agent_util

drw-rw 1

...

now, this agent_util has a .c and .h file.

From 1, using the make file and having lib_java_crw.o , you should be able to compile it without problems. What I suggest is to just change the makefile a bit to fit your compiler and OS. The agent_util.o will be generated wit this. If you dont want to do this, just refer to options and flags to do the same.

with regards

Vaishak Belle

grokmenowa at 2007-7-15 4:54:42 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...