title: Print in Java without changing default printer - Windows 10
body: <p>i am printing something with java and i noticed that my Systemwide Defaultprinter changes to the printer i used the last time. Why is that? 
  My programm shouldnt do that. Any Ideas?</p>
  
  <pre><code>        String printerNameDesired = "Adobe PDF";
      PrintService[] service = PrinterJob.lookupPrintServices(); // list of printers
      DocPrintJob docPrintJob = null;
      int count = service.length;
      for (int i = 0; i &lt; count; i++)
      {
          if (service[i].getName().equalsIgnoreCase(printerNameDesired))
          {
              docPrintJob = service[i].createPrintJob();
              i = count;
          }
      }
      PrinterJob job = PrinterJob.getPrinterJob();
      try
      {
          job.setPrintService(docPrintJob.getPrintService());
      }
      catch (PrinterException ex)
      {
          Logger.getLogger(HelloWorldPrinter.class.getName()).log(Level.SEVERE, null, ex);
      }
  
      PageFormat pf = job.defaultPage();
      Paper paper = new Paper();
      int margin = 0;
      paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight() - margin * 2);
      pf.setPaper(paper);
  
      job.setPrintable(this, pf);
      //boolean ok = job.printDialog(); //ruft den auswahl-dialog auf
      try
      {
          job.print();
      }
      catch (PrinterException ex)
      {
          Logger.getLogger(HelloWorldPrinter.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>The printerservice lastly used at "job.print();" is set as the defaultprinter in Windows "Devices and Printers".
  Tnaks for any help</p>