Antonio Fruci
Antonio Fruci

Reputation: 65

List which ports my Java application is using

I am developing a simple Java video streaming application using JavaFX. I can't use other libraries (vlcj) because of licensing. Anyway, my player works pretty fine, but I need to know on which local port it establishes connection. Since it seems that JavaFX doesn't offer such possibility, I am wondering if there is a way to catch/list all the Java opened connections/sockets.

Code follows, thanks in advance.

String mediaURL = "somepath";
Group root = new Group();
Scene scene = new Scene(root, 640, 480);
Media media = new Media(mediaURL);
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
MediaView mediaView = new MediaView(mediaPlayer);
mediaView.setCache(false);
root.getChildren().add(mediaView);

Upvotes: 2

Views: 4113

Answers (1)

ericson
ericson

Reputation: 1658

On linux/mac, open a terminal and:

  1. use jps command to find the pid of your java process
  2. use lsof -p <pid> |grep ESTABLISHED to list the established connections.

For windows you can check this SO post.

Upvotes: 4

Related Questions