Link to home
Start Free TrialLog in
Avatar of frankdoc
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
Avatar of Merete
Merete
Flag of Australia image

You could use the Java de-compiler to convert java class files into source ... HTML, RTF(Rich Text Format), Plain-text, Unix man pages, single HTML file

Java Decompiler HOW-TO
http://www.linuxjunkies.org/html/Java-Decompiler-HOWTO.html
ASKER CERTIFIED SOLUTION
Avatar of KirillMueller
KirillMueller

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KirillMueller
KirillMueller

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\javadecompiler.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.
Avatar of frankdoc

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\classes
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.
KirillMuller,

Many thanks, it's working

dak
Use DJ Java Decompiler - http://www.neshkov.com/dj.html