关于api:无法运行JProfiler脱机示例的TestProgram

couldn't run the TestProgram of JProfiler offline sample

全部

在Windows PC上脱机运行JProfiler7的示例时遇到错误,代码来自" jprofiler7 \\\\ api \\\\ samples \\\\ offline \\\\ src \\\\ TestProgram.java",并收到消息因此:

JProfiler> A different instance of the native library has been

JProfiler> loaded. Please check the appropriate environment

JProfiler> variable. (PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH)

JProfiler> Exiting.

我确定没有任何JProfiler进程正在运行,并且我已经通过" agent.jar"导入了引用的库并设置了JProfiler的PATH:

C:\\Users\\user>echo %PATH%

C:\\Program Files\\Java\\jdk1.6.0_33\\bin;C:\\Program Files\\java\\jdk1.6.0_33\\jre\\bin;C:\\Program Files\\jprofiler7\\bin\\windows-x64;C:\\Program Files\\jprofiler7\\bin;

我想使用JProfiler API进行远程处理,有人知道如何解决吗?

JProfiler:7.2.3
Windows:Win7 Enterprise SP1
JDK:1.6.0_33

如果我使用以下参数:

1
-agentlib:jprofilerti=offline,id=4321,config=C:\\Program Files\\jprofiler7\\config\\config.xml"-Xbootclasspath/a:C:\\Program Files\\jprofiler7\\bin\\agent.jar"

会有另一条消息:

1
2
3
4
5
6
7
8
9
10
11
    Exception in thread"main" java.lang.NoClassDefFoundError: com/jprofiler/agent/ControllerImpl
    at com.jprofiler.api.agent.Controller.startCPURecording(Controller.java:87)
    at TestProgram.main(TestProgram.java:31)
Caused by: java.lang.ClassNotFoundException: com.jprofiler.agent.ControllerImpl
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 2 more

____________编辑2014.05.08 17:04 CST __________________________________

我尝试运行平台演示(jprofiler7 \\\\ api \\\\ samples \\\\ platform \\\\ src-profiler \\\\ TestProfiler.java),在没有args和带有args的情况下得到了相同的消息(-agentpath:C: \\\\ Program Files \\\\ jprofiler7 \\\\ bin \\\\ windows \\\\ jprofilerti.dll = offline,id = 112,config =" C:\\\\ Program Files \\\\ jprofiler7 \\\\ config \\\\ config.xml -Xbootclasspath / a: C:\\\\ Program Files \\\\ jprofiler7 \\\\ bin \\\\ agent.jar):

1
2
3
4
    JProfiler> A different instance of the native library has been
JProfiler> loaded. Please check the appropriate environment
JProfiler> variable. (PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH)
JProfiler> Exiting.

————————————————————结束—————————————————————————— ——————————————————
解决了。
以我的方式,首先,我使用VM args

启动Java应用程序

1
"-agentpath:C:\\Program Files\\jprofiler7\\bin\\windows-x64\\jprofilerti.dll=port=8849"

然后我用args运行JProfiler platfrom程序:

1
-agentpath:C:\\Program Files\\jprofiler7\\bin\\windows\\jprofilerti.dll=offline,id=112,config="C:\\Program Files\\jprofiler7\\config\\config.xml -Xbootclasspath/a:C:\\Program Files\\jprofiler7\\bin\\agent.jar

然后我可以捕获一些值为null的信息。

1
2
3
4
5
6
7
8
Profiling data :
Memory data:

Exception in thread"main" java.lang.NullPointerException
    at com.jprofiler.core.comm.d.a.getTotalHeapUsage(ejt:100)
    at TestProfiler.dumpMemoryData(TestProfiler.java:82)
    at TestProfiler.dumpProfilingData(TestProfiler.java:55)
    at TestProfiler.main(TestProfiler.java:47)

总而言之,它可以运行...因此结束了问题。


替换-agentlib VM参数

-agentpath:C:\\\\ Program Files \\\\ jprofiler7 \\\\ bin \\\\ windows \\\\ jprofilerti.dll = offline,...

并删除-Xbootclasspath VM参数