从命令行执行jar时出错
当我从命令行触发以下命令时: D:\workspace 2\project\lib>java -javaagent:myagent.jar -cp asm-all-3.3.jar;。 AgentMain
我收到以下错误
java.lang.NullPointerException
java.lang.NullPointerException
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.VerifyError: method(init) (Ljava/lang/String;) V not found
java.lang.NullPointerException
Couldnot find the main class AgentMain. Program will exit.
我在工作目录中拥有所有文件和 jar。 AgentMain 是我从 bin 文件夹放在这里的编译类。我不知道是什么问题。
When I fire the following from command line:
D:\workspace 2\project\lib>java -javaagent:myagent.jar -cp asm-all-3.3.jar;. AgentMain
I get the following error
java.lang.NullPointerException
java.lang.NullPointerException
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.VerifyError: method(init) (Ljava/lang/String;) V not found
java.lang.NullPointerException
Couldnot find the main class AgentMain. Program will exit.
I have all the files and jar in the working directory. AgentMain is the compiled class that I put it here from the bin folder. I dont know what is the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会先检查Agent是否实施正常?
您确实遵循了 中规定的结构java.lang.instrument (
public static void premain(String agentArgs);
) 包括 MANIFEST 条目? Agent 没有办法在初始化期间抛出 NPE 吗?另外,您可能想通过运行 java -javaagent:myagent.jar -cp asm-all-3.3.jar; 来尝试它是 Agent 还是 AgentMain.class。 -版本
I would check first whether the Agent is implemented OK?
You did follow the structure as set forth in java.lang.instrument (
public static void premain(String agentArgs);
) including the MANIFEST entries? And there's no way that the Agent can throw NPEs during initialization?Also, you may want to try out wheter it's the Agent or the AgentMain.class, by running
java -javaagent:myagent.jar -cp asm-all-3.3.jar;. -version
您是否尝试过将类路径设置为当前文件夹(-cp .)?
Have you tried setting the classpath to the current folder (-cp . ) ?