Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: problem for writing to parallel port LPT1 on windows by RXTX library

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Thanked 0 Times in 0 Posts

    Unhappy problem for writing to parallel port LPT1 on windows by RXTX library

    Hello friends,

    I have problem in my java application and rxtx library .

    my application recives some events in observer mechanism and for each event sends event description to printer on parallel port(LPT1 in win) by rxtxcomm.

    my application works fine on linux but on windows, after receiving some events and prints them , the crash happend .

    public class PrinterPortCommunication {
        static PrinterPortCommunication instance = null;
        public final String[] PORT_TYPE = {"Serial Port", "Parallel Port"};
        private String parallelPortName = null;
        private OutputStream outputStream = null;
        private ParallelPort parallelPort = null;
        private CommPortIdentifier port = null;
        static int lineCountLimit = 0;
        static byte[] headerByte = null;
        static int lineCounter = 0;
        private static Logger logger = Logger.getLogger(PrinterPortCommunication.class);
        public static PrinterPortCommunication getInstance() {
            if (instance == null) {
                instance = new PrinterPortCommunication();
            return instance;
        public void init(String parallelPortName, String headerText, int lineCountLimit) throws OnlinePrintException {
            try {
                this.parallelPortName = parallelPortName;
                PrinterPortCommunication.lineCountLimit = lineCountLimit;
                headerText = headerText + " \n";
                headerByte = headerText.getBytes("UTF8");
                port = CommPortIdentifier.getPortIdentifier(parallelPortName);
                parallelPort = (ParallelPort) port.open("EventRecorder", 50);
                outputStream = parallelPort.getOutputStream();
                logger.info("\nport.portType = " + port.getPortType());
                logger.info("port type = " + PORT_TYPE[port.getPortType() - 1]);
                logger.info("port.name = " + port.getName());
            } catch (IOException ex) {
                throw new OnlinePrintException("No paper to print->" + "outputStream" + "\n");
            } catch (Exception ex) {
                throw new OnlinePrintException("can not fine this port->" + parallelPortName + "\n");
        public void print(String printerCodes) throws OnlinePrintException {
            try {
                printerCodes = printerCodes + " \n";
                byte[] byteArray = printerCodes.getBytes("UTF8");
                if (lineCounter == lineCountLimit) {
                    lineCounter = 0;
            } catch (Exception ex) {
                throw new OnlinePrintException("Error in port's outputStream.first initiate the         PrintPortCommunication class.\n");
    code to send print:
     PrinterPortCommunication.getInstance().init("LPT1", "", 5);
       public synchronized void update(Observer observer, final Object obj) {
            try {
                            PrinterPortCommunication.getInstance().print("event description....");
                catch (Exception ex) {
                logger.warn("***Exception***" + ex.toString());
    after reciving events in each second or less ,the crash happend with this error:


    # A fatal error has been detected by the Java Runtime Environment:


    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c92ae22, pid=3784, tid=3608


    # JRE version: 6.0_16-b01

    # Java VM: Java HotSpot(TM) Server VM (14.2-b01 mixed mode windows-x86 )

    # Problematic frame:

    # C [ntdll.dll+0x2ae22]


    # If you would like to submit a bug report, please visit:

    # HotSpot Virtual Machine Error Reporting Page

    # The crash happened outside the Java Virtual Machine in native code.

    # See problematic frame for where to report the bug.


    --------------- T H R E A D ---------------

    Current thread (0x0f274400): JavaThread "NioProcessor-1" [_thread_in_native, id=3608, stack(0x10c40000,0x10e40000)]

    siginfo: ExceptionCode=0xc0000005, reading address 0x45442f35


    EAX=0x33382d45, EBX=0x00000000, ECX=0x45442f35, EDX=0x0ffa0608

    ESP=0x10e3f3fc, EBP=0x10e3f4b8, ESI=0x0ffa52c0, EDI=0x0ffa0000

    EIP=0x7c92ae22, EFLAGS=0x00010217

    Top of Stack: (sp=0x10e3f3fc)

    0x10e3f3fc: 0ffa52e0 0ffa52e0 0f274510 00000000

    0x10e3f40c: 00000008 090c36a0 10e3f498 10e3f434

    0x10e3f41c: 6dc932fb 090c0070 0000001a 090c0ae8

    0x10e3f42c: 000001a4 0e126b48 00000040 6dcd3415

    0x10e3f43c: 00000000 45442f35 10e3f498 33382d45

    0x10e3f44c: 0ffa52c0 00000000 00000000 00020978

    0x10e3f45c: 7c80a6fe 00000000 0ffa52a8 00000000

    0x10e3f46c: 0f274510 7c9106eb 000006f4 00000000

    Instructions: (pc=0x7c92ae22)

    0x7c92ae12: 75 cc 89 75 94 8b 06 89 45 90 8b 4e 04 89 4d 88

    0x7c92ae22: 8b 11 3b 50 04 0f 85 93 d1 ff ff 3b d6 0f 85 8b


    can any body help me please?!
    Last edited by helloworld922; April 19th, 2010 at 09:35 AM.

  2. #2
    Member wolfgar's Avatar
    Join Date
    Oct 2009
    the middle of the woods
    Thanked 1 Time in 1 Post

    Default Re: problem for writing to parallel port LPT1 on windows by RXTX library

    the only diffrence that i know of that might cause this is linux uses the forward slash and windows uses the back slash (or the other way around , i dont remember ) in the file paths , that may cause it , but really idk whats causing it
    Programming: the art that fights back

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Thanked 0 Times in 0 Posts

    Default Re: problem for writing to parallel port LPT1 on windows by RXTX library

    Thanks a lot for your attention but I didnt use any path in my code...

Similar Threads

  1. Problem running .jar in Windows 7
    By SpiceProgrammer in forum Java Theory & Questions
    Replies: 3
    Last Post: December 21st, 2011, 01:28 AM
  2. creating a shared library
    By navinbecse in forum Threads
    Replies: 1
    Last Post: April 9th, 2010, 07:54 AM
  3. theory about serial / parallel port & java
    By wolfgar in forum Java Theory & Questions
    Replies: 5
    Last Post: January 4th, 2010, 10:08 PM
  4. Serail Port Programming regarding phone line hook
    By maskey_dipesh in forum Java SE APIs
    Replies: 2
    Last Post: September 4th, 2009, 05:12 AM
  5. Replies: 1
    Last Post: October 7th, 2008, 07:35 AM