6

I have an exam and I would like to print my Java (in NetBeans project) files as fast as possible. I was wondering is there a way to print an entire project/project in NetBeans with one click? or do you have a better suggestion? (I will be using Windows XP and there is no nice editor like Gedit or Kate installed)

şaloma
  • 417
  • 2
  • 5
  • 16
  • Would you have access to the windows shell? Might be worth learning in advance how to write a quick cmd or powershell script that would recursively search a directory tree for .java files and print them? (I'm assuming you're not allowed to take any code in with you) If you're generating a lot of files then re-writing the script from memory might work out faster than printing them by hand. You've got to wonder what they'll do with the code listings once they're printed out though? O.o – John Carter Jun 04 '10 at 19:02
  • i will only have access to windows shell not the powershell. i can recursively search for .java files but have no idea how to invoke the printing service. oh also, i am allowed take printouts with me. – şaloma Jun 05 '10 at 11:17

4 Answers4

4

Give that the identical question on the netbeans forum from last year is not answered yet, I would say no.

When I needed to print off my final year Comp Sc project (needed to hand in a full print out + polished install CD, oh the poor trees that died for that one...), I opened every file then went through and did a print & close on each one. :(

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • that blows...hopefully they will implement such a feature. our age might be digital but institutions still demand reports and exam answers in paper. i will probably just waste ½hour to print it during the exam. – şaloma Jun 04 '10 at 00:21
2

It can be done. Switch to file mode, select all files, open all, then print. From http://dgreen.github.io/blog/2010/11/02/printing-multiple-files-in-netbeans/

Ludovic Kuty
  • 4,868
  • 3
  • 28
  • 42
DaveG
  • 21
  • 2
1

I had the same problem. I am in a Computer Science class with Java Programming. My homework asignment involves creating a project with many class files (7 at the moment) so I searched google for how to print out the project and found nothing. However, I have come up with a bit of a kludgy way to do this, after reading it you can be the judge of how much time it will actually save. The more classes you have in a single project, the more time it will save. The methodology is kludgy because it involves as little system access as possible, because as you said you are on a school computer so I will assume only the most basic access. It DOES require command prompt access, so this may not be helpful for you. However, it is possible that if you cannot open the command prompt you may be able to execute a .bat file. So here goes.


  • Point command prompt to your source directory and type:

    dir /b > projectDir.txt
    

    or save that 1 line in a text editor as dir.bat

    this will give you a text file listing all of the java files in your source directory

  • open notepad and type this 1 line

    /*PAGEBREAK*/
    
  • save that file as pagebreak.txt
  • now, open the projectDir.txt file you created with Notepad.
  • do a global replace of ".java" with ".java+pagebreak.txt+"
  • get rid of the line that has projectDir.txt listed
  • save the file as projectDir.html
  • open this file in a web browser. the point of this is to get rid of the line breaks created by using dir /b.
  • now, copy this line of text and paste it into a new notepad window. at the beginning of the line, add "copy /b " and at the end of the line, replace the final "+" with " wholeProject.java"
  • run your bat file. if everything has been successful, you will have a single java file containing all of your classes. add this file to your project tree in netBeans IDE.
  • Export that file as an HTML file. one problem is that if you use line numbers, the numbers will be continuous; each new class will not start with 1, so I would advise against that.
  • Open up the html file in notepad. Do a global replace of "/*PAGEBREAK*/" with "<p style='page-break-before: always'>". Save your file, open it in a browser.
  • When you print it, it should print each class on its own page.

hope this helps! netBeans should really implement this though, my method is pretty goofy and contrived.

Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129
Seth Cohen
  • 11
  • 1
0

I found a new way (I hope it is a new way...)

  1. You first want to copy the html , you can do that by choosing "Print to HTML ... " option from the Netbeans settings and choose the " Print to Clipboard " option .
  2. Open the any text app and paste it , save with .html extension .
  3. Now you can use from any browser to print the way you want it .