Last active
June 19, 2025 14:43
-
-
Save chabala/6d71b629c4c09096dec783122212ef73 to your computer and use it in GitHub Desktop.
List all serial ports detected by jSSC (java-simple-serial-connector) heuristics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//JAVA 8 | |
//DEPS org.slf4j:slf4j-nop:1.7.36 | |
//DEPS io.github.java-native:jssc:2.10.2 | |
import jssc.SerialPortList; | |
import java.util.Arrays; | |
public class JsscPortList { | |
public static void main(String[] args) { | |
String[] portNames = SerialPortList.getPortNames(); | |
if (portNames != null && portNames.length > 0) { | |
System.out.println("Serial ports detected: " + | |
String.join(" ", Arrays.asList(portNames))); | |
} else { | |
System.out.println("No serial ports detected by jSSC"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ jbang https://gist.github.com/chabala/6d71b629c4c09096dec783122212ef73