-2

How do I convert multiple folders containing .java files to .class files having the same hierarchy? I mean just convert the .java files to .class in one go

Dario Dias
  • 817
  • 6
  • 19
  • 32
  • Use `javac *.java` for compiling all files inside one folder ! – ItachiUchiha Jul 27 '14 at 09:31
  • he is not asking inside one folder. he is asking for multiple folders @ItachiUchiha – Deepanshu J bedi Jul 27 '14 at 09:33
  • Sorry for posting an answer @DavidPostill didnt see that comment :(. – Deepanshu J bedi Jul 27 '14 at 09:34
  • SORRY no offense, but it is easy to mark a thread as duplicate but not as easy for everyone to find a thread similar to the question one wants to ask.I am looking for some command like set src=dir /s /b /o:n /ad to list the directory structure with sub directories then use javac %src%\*.java to convert all .java files in the sub directories to .class file then delete the .java files – Dario Dias Jul 27 '14 at 11:21
  • Why would you want to delete the .java files? How would you like to handle a compile error where no .class is generated and your .java has been deleted? – DavidPostill Jul 27 '14 at 17:25
  • I would delete the java files after successfully compiling the files into class file.the thread "Java: How can I compile an entire directory structure of code?" does not give how to automatically find and compile all java files in the directory and its sub-directories. – Dario Dias Jul 27 '14 at 18:48

1 Answers1

0
javac /yourdir/*.java /yourdir2/*.java

just add the directories from which you want to compile.

Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23
  • :For that I would have to type each and every folder and its sub-folders name which is not practical in case of multiple folders.@DavidPostill:I am not deleting the original .java files.Will make .class files of a copy of j.ava files – Dario Dias Aug 25 '14 at 06:36