user60787: I am using a third-party program to build the binary file and upload it under Arduino IDE's GUI, meaning I am not using the built-in avr-gcc nor avrdude for building and uploading. As there is a on-board DAP chip, uploading binary file is done by copy&paste the binary file into the flash memory recognized as a removable storage by the OS.
However, this make reading user's current port selection very difficult because the IDE is written in Java, but the thrid-party program I am using is in C++. 
Knowing which port the user has currently selected is very important to me, as sometimes I need to program multiple boards at the same time and monitor their received data on the serial port.
If someone can point me into the right direction or link me to the previously-solved similar question , it will be much appreciated!
PS: I am working under Ubuntu&Windows10 OS and using latest Arduino IDE.  

user60787: After someone from Github gave me a link, I think I ve found the way to read the real-time port selection even using third party uploading program.
The key is command line argument in the "Platform.txt" file located under "arduino15" folder. If you have the same issue as mine, try look up this link, where you will find loads of useful information:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
PS: rmb, after you change the command lines in the txt file, always close and restart your arduino IDE before those changes you made take effect.

60787: <p>I am using a third-party program to build the binary file and upload it under Arduino IDE's GUI, meaning I am not using the built-in avr-gcc nor avrdude for building and uploading. As there is a on-board DAP chip, uploading binary file is done by copy&amp;paste the binary file into the flash memory recognized as a removable storage by the OS.</p>

<p>However, this make reading user's current port selection very difficult because the IDE is written in Java, but the thrid-party program I am using is in C++. </p>

<p>Knowing which port the user has currently selected is very important to me, as sometimes I need to program multiple boards at the same time and monitor their received data on the serial port.</p>

<p>If someone can point me into the right direction or link me to the previously-solved similar question , it will be much appreciated!</p>

<p>PS: I am working under Ubuntu&amp;Windows10 OS and using latest Arduino IDE.  </p>
 60787: <p>After someone from Github gave me a link, I think I ve found the way to read the real-time port selection even using third party uploading program.</p>

<p>The key is command line argument in the "Platform.txt" file located under "arduino15" folder. If you have the same issue as mine, try look up this link, where you will find loads of useful information:
<a href="https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification" rel="nofollow noreferrer">https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification</a></p>

<p>PS: rmb, after you change the command lines in the txt file, always close and restart your arduino IDE before those changes you made take effect.</p>
