this is the simple printing.
import java.awt.*;
import java.io.*;
public class lpt
{
public static void main (String[] argv)
{
//check for argument
if (argv.length != 1)
{
System.out.println("usage: java lpt <printer name>"

;
System.exit(0);
}
try
{
//open printer as if it were a file
FileOutputStream os = new FileOutputStream(argv[0]);
//wrap stream in "friendly" PrintStream
PrintStream ps = new PrintStream(os);
//print text here
ps.println("Hello world!"

;
//form feed -- this is important
//Without the form feed, the text
//will simply sit in the print
//buffer until something else
//gets printed.
ps.print("\f"

;
//flush buffer and close
ps.close();
}
catch (Exception e)
{
System.out.println("Exception occurred: " + e);
}
}
}