Search code examples
javaeclipse.class-file

How to compile .class files


I am new to Java, I have some *.class files which needs to be modified. Now I de-compiled these *.class files to get the source code using the famous JD Decompiler. The concern is after I change the code and need to recompile these *.class files how will I do it with Eclipse. I only the compiled *.class files.

I know its a stupid question but bear with me I'm .NET Developer with a few days into Java.


Solution

  • You can not compile a *.class file, Its already compiled code (bytecode) for its *.java source. I think you need to copy the code from JD Decompiler's editor to a java source file.

    i.e. copy the source code from JD's editor for Hello.class into a file named Hello.java. Now you can move this file in IDE of your choice or directly compile using javac. (dont forget to put all the dependencies/required jars/source in project build path)