• JPDA Trace好不容易找到的 规格严格


    JPDA Trace tool not picking up classpath
    发布: 2007-8-23 下午3:11
    Click to report abuse...   点击回复此主题 回复
    Hello:

    I created a Hello class and followed the instruction on http://java.sun.com/j2se/1.5.0/docs/guide/jpda/trace.html for Tracing the method calls at runtime. However while launching Trace tool, it does not seem to use the classpath setting in order to find my Hello class. Hello.java does not have package directive and is created in "D:\tmp\java-example". As shown below in Step 1, if I run my program from D:\tmp\java-example then the Trace tool is able to find the program. However if I am in any other directory and set D:\tmp\java-example in the CLASSPATH (as shown in Step 2 below) or provide it as value to jvm -classpath argument (as shown in Step 3 below) then the Trace tool is unable to find my Hello class.

    Step 1:
    D:\tmp\java-example>java com.sun.tools.example.trace.Trace Hello
    -- VM Started --
    ====== main ======
    main -- Hello
    | <init> -- Hello
    | methodA -- Hello
    | | methodC -- Hello
    | methodB -- Hello
    ====== main end ======
    -- The application exited --


    Step: 2

    D:\tmp\java-example>echo %CLASSPATH%
    "D:\tmp\java-example\;C:\Program Files\Java\jdk1.6.0\lib\Tools.jar;C:\Program Files\Java\jdk1.6.0\demo\jpda\;"

    D:\tmp\java-example>cd ..

    D:\tmp>java com.sun.tools.example.trace.Trace Hello
    java.lang.NoClassDefFoundError: Hello
    Exception in thread "main" -- VM Started --
    -- The application exited --


    Step: 3
    D:\tmp>java -classpath "D:\tmp\java-example\;C:\Program Files\Java\jdk1.6.0\lib\
    Tools.jar;C:\Program Files\Java\jdk1.6.0\demo\jpda\;" com.sun.tools.example.trac
    e.Trace Hello
    java.lang.NoClassDefFoundError: Hello
    Exception in thread "main" -- VM Started --
    -- The application exited --

    Any help is much appreciated.

    Thanks,

    840807

    发贴数: 49,988
    注册时间: 11-03-01
    Re: JPDA Trace tool not picking up classpath
    发布: 2007-11-19 上午12:32   回复: 840807 回复: 840807
    Click to report abuse...   点击回复此主题 回复
    Hi
    Have you find how to solve this issue?
    840807

    发贴数: 49,988
    注册时间: 11-03-01
    Re: JPDA Trace tool not picking up classpath
    发布: 2007-11-19 上午2:52   回复: 840807 回复: 840807
    Click to report abuse...   点击回复此主题 回复
    Hi.
    After all, it was small bag in the Trace example:
    In the method Trace.connectorArguments(..) handling of class path should be added:
    Map connectorArguments(LaunchingConnector connector, String mainArgs) { 
            Map arguments = connector.defaultArguments(); 
            Connector.Argument mainArg = 
                       (Connector.Argument)arguments.get("main"); 
            if (mainArg == null) { 
                throw new Error("Bad launching connector"); 
            } 
            mainArg.setValue(mainArgs); 
            // Begin of the fix 
            Connector.Argument optsArg = 
                       (Connector.Argument)arguments.get("options"); 
            if (optsArg == null) { 
                throw new Error("Bad launching connector"); 
            } 
            String cp = "-Djava.class.path="+System.getProperty("java.class.path";); 
            optsArg.setValue(cp); 
           // End of the fix
    

    That's all.
    user5344869

    发贴数: 101
    注册时间: 10-09-25
    Re: JPDA Trace tool not picking up classpath
    发布: 2007-12-19 上午8:04   回复: 840807 回复: 840807
    Click to report abuse...   点击回复此主题 回复
  • 相关阅读:
    浅谈三层架构
    尺度空间(Scale space)理论
    漫游Kafka实现篇之消息和日志
    杭电 2095
    .net调用Outlook 批量发送邮件,可指定Outlook中的账号来发送邮件
    Java实现 蓝桥杯VIP 算法提高 计算时间
    Java实现 蓝桥杯VIP 算法提高 计算时间
    Java实现 蓝桥杯VIP 算法提高 计算时间
    Java实现 蓝桥杯VIP 算法提高 计算时间
    Java实现 蓝桥杯VIP 算法提高 最小乘积(提高型)
  • 原文地址:https://www.cnblogs.com/diyunpeng/p/2240488.html
Copyright © 2020-2023  润新知