how to trace the method calls sequence

I have a class like this

public class TestTraceMethods
{
public static void main(String[] args)
{
TestTraceMethods test = new TestTraceMethods();
test.testMe();
Runtime.getRuntime().traceMethodCalls(true);
// Thread.currentThread().dumpStack();
// (new Throwable()).printStackTrace( System.out );
}

public void testMe()
{
System.out.println("Hello World!");
}
}

here JVM is ignoring this--> Runtime.getRuntime().traceMethodCalls(true);

then i refered API

there i found that

Enables/Disables tracing of method calls. If the boolean argument is true, this method suggests that the Java virtual machine emit debugging information for each method in the virtual machine as it is called. The format of this information, and the file or other output stream to which it is emitted, depends on the host environment. The virtual machine may ignore this request if it does not support this feature.


then how can i set host environment to get log file or format of this information.



LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
Tracing only works with the debug version of java apparently....  

Try using 'java_g' instead of 'java'.
0
TimYatesCommented:
Hehe, I can't find a java_g...so looks like that info was wrong...

is this any better?

public static void main(String[] args)
{
    Runtime.getRuntime().traceMethodCalls(true);
    TestTraceMethods test = new TestTraceMethods();
    test.testMe();
}

ie: turn it on before you do anything?
0
zzynxSoftware engineerCommented:
>> Try using 'java_g' instead of 'java'.
java -Xdebug
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

TimYatesCommented:
Nope...after a bit more research, this flag isn't supported by most JVMs

Apparently you can get (or build?) a debug jvm from Sun which will support it...but by default they do nothing when you turn this on...

What are you trying to do?  Profile your application?  Why not try a java profiler?

http://www.javaworld.com/javaworld/javatips/jw-javatip92.html
0
zzynxSoftware engineerCommented:
0
zzynxSoftware engineerCommented:
I read somewhere:

1. I m trying to use java_g / jdb pair in the windows environment.
    I couldn't find java_g in JDK 1.2 package. Was it replaced with something else?
2. I don’t get any output when I do a
      Runtime.traceMethodCalls(true ).
    I was expecting all the function calls to be traced. Does this mean that the JDK doesn’t support this on windows?

Answer: I think they changed this at some point.
             I currently:

             1) Compile everything using: javac -g
             2) Run using:
                     java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 YourClassName

http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/java.html
http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/jdb.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzynxSoftware engineerCommented:
Hi chaituu, what about closing some of your open questions (15)?
0
chaitu chaituAuthor Commented:
i AM SATISFIED with the answers  of some of the questions;

i will update some questions in 2 or 3 days time;

i will replied to some of the questions but not get replies
0
zzynxSoftware engineerCommented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.