frankdoc
asked on
how to convert java .class files to .txt or .html files in a batch motion?
Is it possible to run some code or software to convert java *.class files into *.html or *.txt files in a batch motion?
For example, I have 20 .class files in one directory, is it possible to run a code/software to convert all of them to .txt files?
Thanks,
Dak
For example, I have 20 .class files in one directory, is it possible to run a code/software to convert all of them to .txt files?
Thanks,
Dak
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, there's a typo in my post. Corrected version below:
Find a suitable Java decompiler and test it for one .class file. Once you have your command line, like
C:\SomePath\javadecompiler .exe test.class /x /y /z
, use the FOR construct to process all files in a directory using your command line:
rem -------- test.cmd ------------
cd C:\Path\With\Class\Files
for %%f in (*.class) do C:\SomePath\javadecompiler .exe %%f /x /y /z
Replace the "C:\SomePath\javadecompile r.exe %%f /x /y /z" part with "echo %%f" to check if the script works at all.
Some decompilers might accept file patterns like *.class, but the FOR approach is fail-safe.
Find a suitable Java decompiler and test it for one .class file. Once you have your command line, like
C:\SomePath\javadecompiler
, use the FOR construct to process all files in a directory using your command line:
rem -------- test.cmd ------------
cd C:\Path\With\Class\Files
for %%f in (*.class) do C:\SomePath\javadecompiler
Replace the "C:\SomePath\javadecompile
Some decompilers might accept file patterns like *.class, but the FOR approach is fail-safe.
ASKER
KirillMueller,
Thanks for your tip. On the command line, I tried your code with one class and the .txt file popped up. I guess it's a success (I am hoping no pop-up).
I then created a .cmd file with 2 lines of code, shown below. The first line goes to the directory classess where all the class files are saved.
cd D:\Programming\Java\classe s
for %%f in (*.class) do D:\Programming\Java \dj.exe %%f
However, it doesn's work. Where did I miss?
Regards,
Dak
Thanks for your tip. On the command line, I tried your code with one class and the .txt file popped up. I guess it's a success (I am hoping no pop-up).
I then created a .cmd file with 2 lines of code, shown below. The first line goes to the directory classess where all the class files are saved.
cd D:\Programming\Java\classe
for %%f in (*.class) do D:\Programming\Java \dj.exe %%f
However, it doesn's work. Where did I miss?
Regards,
Dak
You have a space in your path to dj.exe -- is that a copy-paste error?
Do you get any error messages? Try appending a
pause
command at the end of your .cmd file to see error output.
Do you get any error messages? Try appending a
pause
command at the end of your .cmd file to see error output.
ASKER
KirillMuller,
Many thanks, it's working
dak
Many thanks, it's working
dak
Use DJ Java Decompiler - http://www.neshkov.com/dj.html
Java Decompiler HOW-TO
http://www.linuxjunkies.org/html/Java-Decompiler-HOWTO.html