?
Solved

how to convert java .class files to .txt or .html files in a batch motion?

Posted on 2007-10-01
7
Medium Priority
?
5,627 Views
Last Modified: 2010-10-05
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
0
Comment
Question by:frankdoc
7 Comments
 
LVL 70

Expert Comment

by:Merete
ID: 19994616
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
0
 
LVL 5

Accepted Solution

by:
KirillMueller earned 2000 total points
ID: 19994737
Find a suitable Java decompiler and test it for one .class file. Once you have your command line, like

C:\SomePath\javadecompiler.exe %%f /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.
0
 
LVL 5

Expert Comment

by:KirillMueller
ID: 19994743
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:frankdoc
ID: 20002411
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
0
 
LVL 5

Expert Comment

by:KirillMueller
ID: 20002445
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.
0
 

Author Comment

by:frankdoc
ID: 20010078
KirillMuller,

Many thanks, it's working

dak
0
 

Expert Comment

by:neshkov2
ID: 23889954
Use DJ Java Decompiler - http://www.neshkov.com/dj.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn different types of Android Layout and some basics of an Android App.
Simple Linear Regression
Progress

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question