Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
I'd take a look at how Micro Manager does it. This is a software package written in java for use with microscopes, and many of the common microscope automation systems rely on RS-232 communication. I don't know for sure if the java layer has direct access to the serial port, but you can read up on it here: https://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager_Programming_Guide