如何从ant执行javap
我想从 ant 脚本运行 javap 命令。 javap命令位于JDK下的bin文件夹中,但是如何在ant脚本中访问JDK路径? ${java.home} 指向 JRE 而不是 JDK,因此这没有帮助。
我正在寻找一种不需要对系统进行任何配置的解决方案,例如修改 PATH 或设置其他环境变量(如 JAVA_HOME)。仅适用于 Windows 的解决方案就可以了。
I want to run javap command from an ant script. Javap command is located in the bin folder under JDK, but how do I access the JDK path in an ant script? ${java.home} is pointing to the JRE instead of JDK, so that doesn't help.
I'm, looking for a solution which does not require any configuration to the system such as modifying PATH or setting other environment variables like JAVA_HOME. A solution that works only in Windows is fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ant 脚本可以读取外部属性文件。一个简单的解决方案是将
JDK_HOME
属性添加到现有属性文件或 Ant 脚本中。之后,您可以使用JDK_HOME
作为参考来引用javap
工具。此解决方案不需要您更改任何系统属性;这里唯一的要求是您需要知道 JDK 路径。Ant scripts can read external properties file. A simple solution would be to add a
JDK_HOME
property to your existing property file or your Ant script. After that, you can just refer to thejavap
tool usingJDK_HOME
as a reference. This solution doesn't require you to change any system property; the only requirement here is that you need to know the JDK path.首先,谢谢你的提问。我不知道这个实用程序,总是使用 DJ 或 JAD 等外部工具进行反编译。
其次,我不相信你有一个简单的方法。我担心您必须创建自己的平台特定机制来定位 JDK。在 Windows 上使用注册表,并像
在 UNIX 上一样使用命令链接。
First, thank you for the question. I did not know about this utility and always used external tools like DJ or JAD for decompilation.
Second, I do not believe that you have an easy way. I am affraid that you have to create your own platform specific mechanism that locates JDK. Use registry for windows and command linke like
on unix.