How to execute javap from ant

I want to run javap command from ant script. The Javap command is located in the bin folder in the JDK, but how do I access the JDK path in the ant script? $ {java.home} points to the JRE instead of the JDK, so this does not help.

I am looking for a solution that does not require any configuration for the system, such as changing PATH or setting other environment variables such as JAVA_HOME. A solution that only works on Windows is great.

+3
source share
2 answers

Ant scripts can read a file of external properties. A simple solution would be to add the property JDK_HOMEto your existing properties file or your Ant script. After that, you can simply access the tool javapusing JDK_HOMEas a reference. This solution does not require a change in any system property; the only requirement here is that you need to know the JDK path.

+2
source

Firstly, thanks for the question. I did not know about this utility and always used external tools such as DJ or JAD for decompilation.

Secondly, I do not think that you have an easy way. I am afraid that you need to create your own platform-specific mechanism that the JDK finds. Use registry for windows and command line, for example

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

on unix.

+1
source

Source: https://habr.com/ru/post/1779943/


All Articles