There's already quite some text written about this subject, but none provided a real proper solution on how to solve this structurally. Let me first explain briefly: I use an Arduino Mega Rev3, and connect from a PC (Windows 7 64bit) via the USB/serial port with a Java program using the RXTX library. My friend is doing the exact same thing from a Mac (same Arduino, same Java...).
Each time when I open() the serial port in Java, the Arduino reboots (this is the same with many other serial programs). Note that the issue is not related to the Java code (no code posted here), but simply that upon opening the serial port, the DTR line on the Arduino asserts (=goes low). This resets the Arduino via the 100nF cap. This reset is done by design by the Arduino folks, so that the bootloader starts and checks if new code need to be loaded.
HOWEVER, when you are in full running with the Arduino, and want to make a serial connection (for monitoring, control through Java, whatever, ...), you do NOT want to have the Arduino rebooting in the middle of your program. This would be very bad practice.
So I'm looking for a structural solution to this. There are many proposals circulating around the web, many of those changing the Arduino HW. I do not want to make such changes, because the HW should remain untouched. Yes I know there is a solder-jumper that you could cut, but then you loose the ability to be able to load the sketches without pushing the reset button. I'm looking for a transparent solution to all that.
Given the Arduino folks have designed a custom-made solution for sketch upload (DTR asserting to Reset line), and that the recent models of the Arduino boards are no longer using the FT232RL, but an atMega16u2 (or 8u2), I believe it would be more appropriate to update the firmware one way or the other, so that it detects whether there is sketch-upload needed, or any other serial connection, and make decision to assert or not the DTR line.
Any thoughts or ideas are welcome.