What is the problem in this code? It doesn't print the string "Send Mesage" (located) in main(), although it successfully opens the SerialPort and gets the OutputStream. Even if I put lines A and B (in bold) in a while(true) loop, the application still terminates (and not still print the "Send Message"), even though I would have thought it will just indefinitely loop.
[ August 05, 2005: Message edited by: Karen Baog ] [ August 05, 2005: Message edited by: Karen Baog ]
Here Java is handing you a nice explanation, and you are dropping it on the floor with the peanut shells. At least have an e.printStackTrace() in there -- I guarantee it will tell you something useful about what's going wrong.
Now you're getting somewhere -- you know something is null, and you know it's something involved in one specific line of code. There are two variables dereferenced on that line. Ask yourself -- very carefully -- if either of the variables on that line might be null. Even if you think they can't, trace through the program and make sure you can point to the place where each variable used on that line is initialized. I guarantee, again, that you will learn something interesting -- in fact, this time you'll find the problem.