JavaFX UI server socket application demonstrating multiple socket client connections simultaneously.
This application is written in Java using the JavaFX API. It represents the server side of a socket connection and can:
- connect to a socket at a configurable port
- handle multiple client socket connections at the same time and indicate the number of connections
- receive text messages from connected sockets
- send text messages to all connected sockets
- retrieve sent and received messages
It is typically used in conjunction with a client-side JavaFX UI application called SocketClientFX.
It can be found here: https://github.com/jtconnors/SocketClientFX
This version of the source code is tagged 1.1-JDK25-maven. As its name suggests, it is specific to JDK 25 and can be built with the apache maven build lifecycle system. Since JDK 16, the jpackage API has been standardized, and as such the scripts contained in this project could be modified to build with and run with JDKs from JDK 16 onwards. Subsequent releases to JDK 25 have not been tested with this version of the project.
This project works on Windows, MacOS or Linux.
- Your default JDK should point to a valid JDK 25 runtime in your
PATH. - Prior to running any of the scripts in this project, either the
JAVA_HOMEor$env:JAVA_HOME(depending upon the platform in question) environment variable must be set to a valid JDK 25 runtime. - In order to generate
EXEorMSIinstallers for Windows using the scripts in this project, the WiX toolkit version 3.0 or greater must be installed and placed on thePATH. - For certain Linux distributions (e.g. Oracle Linux ...) additional tooling, like for example
rpmbuild, may be required in order to fully utilize thejpackageutility.
Of note, the following maven goals can be executed:
mvn cleanmvn dependency:copy-dependencies- to pull down dependentjavafxandcom.jtconnors.socketmodulesmvn compile- to build the applicationmvn package- to create theMultiSocketServerFXmodule as a jar filemvn exec:javato run the application
The Maven build also includes profiles for creating custom runtime images and native application packages directly from the Maven lifecycle.
To create a trimmed runtime image with jlink, run:
mvn clean package -PjlinkThis builds the application module, copies the runtime dependencies into target/modules, and writes the generated runtime image to target/image.
To create a native application image with jpackage, run:
mvn clean verify -Pjpackage
This first creates the jlink runtime image, then packages the application into target/jpackage. By default, the jpackage profile creates an app-image.
Platform-specific installer profiles are also provided:
mvn clean verify -Pjpackage,jpackage-mac-dmg
mvn clean verify -Pjpackage,jpackage-mac-pkg
mvn clean verify -Pjpackage,jpackage-linux-deb
mvn clean verify -Pjpackage,jpackage-linux-rpm
mvn clean verify "-Pjpackage,jpackage-windows-exe"
mvn clean verify "-Pjpackage,jpackage-windows-msi"
Furthermore, additional .sh and .ps1 files are provided in the sh/ and ps1\ directories respectively:
sh/run.shorps1\run.ps1- script file to run the application from the module pathsh/run-simplified.shorps1\run-simplified.ps1- alternative script file to run the application, determines main class fromSocketClientFXmodulesh/link.shorps1\link.ps1- creates a runtime image using thejlinkutility. Note: the application must be compiled (i.e. mvn package) before the ```link`` script can be executed.sh/create-appimage.shorps1\create-appimage.ps1- creates a native package image of application using JEP-392 jpackage toolsh/create-deb-installer.sh- creates a native Linux DEB installer of this application using JEP-392 jpackage toolsh/create-dmg-installer.sh- creates a native MacOS DMG installer of this application using JEP-392 jpackage toolps1\create-exe-installer.ps1- creates a native Windows EXE installer of this application using JEP-392 jpackage toolps1\create-msi-installer.ps1- creates a native Windows MSI installer of this application using JEP-392 jpackage toolsh/create-pkg-installer.sh- creates a native MacOS PKG installer of this application using JEP-392 jpackage toolsh/create-rpm-installer.sh- creates a native Linux RPM installer of this application using JEP-392 jpackage toolps1\create-generic-msi.ps1- creates a generic MSI installer of the JDK in use for this build, using the JEP-392 jpackage tool
- These scripts have a few available command-line options. To print out
the options, add
--helpas an argument to any script. - These scripts share common properties that can be found in
env.shorenv.ps1. These may need to be slightly modified to match your specific configuration. - A sample
Microsoft.PowerShell_profile.ps1file has been included to help configure a default Powershell execution environment. A similar file can be generated specific to environments appropriate for running thebash(1)shell with a.bash_loginor.bash_profilefile.
- SocketClientFX: https://github.com/jtconnors/SocketClientFX
- SocketServerFX: https://github.com/jtconnors/SocketServerFX
- maven-com.jtconnors.socket: https://github.com/jtconnors/maven-com.jtconnors.socket
