
以下代码实现java调用打印服务遍历打印机（采用java1.4版本开始的原生打印服务），已经通过测试。
===========================================================================
--------------------------------------MyPrint.java-------------------------
import java.awt.print.*;
import javax.print.*;

class MyPrint{
	public static void main(String[] args){
		System.out.println("Hello World!");

            //获得本台电脑连接的所有打印机
            PrintService[] printServices = PrinterJob.lookupPrintServices();
            if(printServices == null || printServices.length == 0) {
                System.out.print("打印失败，未找到可用打印机，请检查。");
                return ;
            }

			PrintService printService = null;
			String printerName = "xx打印机";
		   //遍历打印机
			for (int i = 0;i < printServices.length; i++) {
				System.out.println(printServices[i].getName());
				if (printServices[i].getName().contains(printerName)) {
					printService = printServices[i];
					break;
				}
			}

	}
}
--------------------------------------MyPrint.java-------------------------
javac MyPrint.java
java MyPrint
===========================================================================

以下为网上的JAVA打印资料：

https://www.jianshu.com/p/be0456f5265d
java实现打印功能

https://blog.csdn.net/weixin_39818264/article/details/114032503?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5-114032503-blog-114158354.pc_relevant_3mothn_strategy_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5-114032503-blog-114158354.pc_relevant_3mothn_strategy_recovery&utm_relevant_index=6
java 打印图片_java打印程序——打印图片(不带对话框)

https://blog.csdn.net/weixin_29266007/article/details/114158354?spm=1001.2101.3001.6650.7&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7-114158354-blog-79748598.pc_relevant_multi_platform_whitelistv3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7-114158354-blog-79748598.pc_relevant_multi_platform_whitelistv3&utm_relevant_index=8
java打印图片_java如何调用本地打印机进行图片打印

https://blog.csdn.net/baidu_37366055/article/details/105427208?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-105427208-blog-51754068.pc_relevant_aa2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-105427208-blog-51754068.pc_relevant_aa2&utm_relevant_index=2
JAVA调用打印机

https://blog.csdn.net/dailuwen/article/details/51754068#:~:text=PrintService%20%E4%BD%BF%E7%94%A8%20java%20x.%20print%20%E5%8C%85%E4%B8%8B%E7%9A%84%E7%B1%BB%E6%9D%A5%20%E6%89%93%E5%8D%B0%20%EF%BC%8C%E5%8F%AF%E4%BB%A5,print.pdf%22%29%2C%20DocFlavor.BYTE_ARRAY.PDF%2C%20null%29%3B%20PrintService%20ps%20%3D%20Print%20S
JAVA 本地打印 DocFlavor、DocPrintJob job、PrintService


https://blog.csdn.net/m0_46267097/article/details/112609095
Java调用打印机打印（远程、本地皆可用）

