Skip to content

Instantly share code, notes, and snippets.

@chabala
Last active June 19, 2025 14:43
Show Gist options
  • Save chabala/6d71b629c4c09096dec783122212ef73 to your computer and use it in GitHub Desktop.
Save chabala/6d71b629c4c09096dec783122212ef73 to your computer and use it in GitHub Desktop.
List all serial ports detected by jSSC (java-simple-serial-connector) heuristics
///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");
}
}
}
@chabala
Copy link
Author

chabala commented Jun 19, 2025

$ jbang https://gist.github.com/chabala/6d71b629c4c09096dec783122212ef73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment