开发者

How to execute javap from ant

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 s开发者_StackOverflowolution 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.


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 the javap tool using JDK_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.


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

ls /bin/java*/bin/javac* | tail -1 

on unix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜