Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

open a .class file and copy to .java file

 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need your experts advice on something that I am doing now. I want to open a file which is in .class
format using DJ Decompiler and copy the file into a java file using java program. Actually I want to
get the directory as input and do this for all the files and files inside all the directories. How
can I do this?

Now I have a code to open the DJ Decompiler and also to copy the files, but both are seperate. How to
integrate them?

e.g. I have a folder D:/test in which I have .class files

D:/test/hello.class (There will be many files like this, but for now its 1)

I want to make this file as hello.java file.

Is this possible? Any help would be appriciated.

Thanks
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can be done using the command line decompilers for JAD, DJ Decompiler is just a fancy GUI that suits on top of the command line interface. From that, my guess the way this command line will work like will be something like "program.exe source.class destination.java", so thats not a problem as you could get an array of class names and in some sort of loop, deliver each class name to be decompiled. Or even better, the command line may be able to take a wildcard or do all files in a certain directory.

Also, are you aware that DJ Dompiler can manually do multiple files at once (Tooks>> Compiler...").
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks dude, I got it working now. Your idea was great.

The code I used was


import java.io.*;
import java.util.*;

public class FileReading1
{


public static void main(String [] args)
{

Runtime r = Runtime.getRuntime();
Process p = null;

try
{
p = r.exec("C:/jad/jad.exe -o -r -dD:/TestFolder -sjava D:/TestFolder/**/*.class");
}
catch(Exception e)
{
System.out.println("Error");
e.printStackTrace();

}

It worked the way I wanted and even I got the same package structure

Thanks a lot

}
}
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic