Search code examples
javaeclipsepdfpretty-print

How can I pretty-print multiple Java files to a single page?


I am a teacher and would like my students to have in front of them pretty printouts of the source code to 4 short Java files. I don't want to waste paper (or have them shuffling papers around), so I would like to have the four files on a single page. I don't want to print (from Eclipse) each to a separate PDF, then combine them 4-up, since that would make the text tiny. I tried concatenating the four files into a single .java file in Eclipse, but, despite reading this question, I found no way of suppressing the display of errors (namely defining multiple public classes in a single file).

Update: I don't just want to print the code as text. I would like it pretty-printed, i.e., with syntax highlighting.


Solution

    • You can copy them from eclipse to open/libreoffice or word to keep the formatting, especially the colors.
    • You could use a program like Highlight: http://www.andre-simon.de/ (Results can be copied to with highlighting)
    • You could use Latex to handle the formatting
    • You could put the source together in one file, you have to make the necessary changes to make sure there is only one public class:

      public class a {}

      class B {}