H-CLUS is a Java client-server application for hierarchical clustering of numerical data. It was developed in 2024 for the Advanced Programming Methods (Metodi Avanzati di Programmazione) university course, academic year 2023–2024.
The application reads data from a MySQL database and builds a dendrogram, which is a hierarchy of clusters. Each data point starts in its own cluster. At each level, the two closest clusters are merged until the selected depth is reached.
- Agglomerative hierarchical clustering with single-link and average-link methods.
- Data loading from MySQL tables with numerical columns.
- A multithreaded server that handles client connections using TCP sockets.
- Two clients: a command-line interface and a JavaFX graphical interface.
- Text-based dendrogram output and saving/loading results using Java serialization.
- UML diagrams and Javadoc comments in the source code.
The distance between individual data points is calculated as the sum of squared differences (squared Euclidean distance).
Screenshot from the original 2024 user guide. The interface and source comments are in Italian.
H-CLUS_Base/
Client/src/ Command-line client
Server/src/ Shared server and clustering logic
H-CLUS_Estensione/
Client/src/ JavaFX client and FXML layouts
MySQL/
mySQLScript.sql Sample database setup
UML/ Class and package diagrams
docs/ Application screenshot
Both clients use the same server. The server source is organized into packages for clustering, data, database access and distance calculations.
- JDK 17 (recommended; the original project used Java 16).
- MySQL Server 8.0.
- MySQL Connector/J 8.0.17 (the original JDBC driver).
- JavaFX SDK 17, only for the graphical client. The original launch script used JavaFX 17.0.11.
Download the project using Code > Download ZIP on GitHub and extract it, or clone the repository. Open a terminal in the project root (the folder containing this README).
Start MySQL and open MySQL Workbench or another SQL client with an administrator account. Open and execute MySQL/mySQLScript.sql once on a fresh local MySQL instance. It creates the mapdb database, a read-only demo user and the exampleTab table with five sample rows.
The script does not delete an existing database. If the database or user already exists, check your local setup before running it.
The original connection settings are in DbAccess.java. They use localhost, port 3306 and a fixed demo account. These credentials are only for local testing; do not use them for a real database.
Download MySQL Connector/J 8.0.17 and save the JAR in the project root as mysql-connector-java-8.0.17.jar.
Compile the server:
javac --release 17 -encoding UTF-8 -d build/server -sourcepath H-CLUS_Base/Server/src H-CLUS_Base/Server/src/MultiServer.javaStart the server on port 8080.
Windows (PowerShell or Command Prompt):
java -cp "build/server;mysql-connector-java-8.0.17.jar" MultiServermacOS / Linux:
java -cp "build/server:mysql-connector-java-8.0.17.jar" MultiServerKeep this terminal open. Open a second terminal in the project root to run one of the clients.
javac --release 17 -encoding UTF-8 -d build/cli -sourcepath H-CLUS_Base/Client/src H-CLUS_Base/Client/src/MainTestClient.java
java -cp build/cli MainTestClientThe client connects to 127.0.0.1:8080 by default.
Download the JavaFX SDK for your operating system and extract it. Replace the example SDK path below with the path to its lib folder.
Windows (PowerShell):
$fx = "C:/Java/javafx-sdk-17.0.11/lib"
javac --release 17 -encoding UTF-8 --module-path "$fx" --add-modules javafx.controls,javafx.fxml -d build/gui -sourcepath H-CLUS_Estensione/Client/src H-CLUS_Estensione/Client/src/application/App.java H-CLUS_Estensione/Client/src/application/Welcome.java H-CLUS_Estensione/Client/src/application/Avvia.java H-CLUS_Estensione/Client/src/application/Program.java
java --module-path "$fx" --add-modules javafx.controls,javafx.fxml -cp "build/gui;H-CLUS_Estensione/Client/src" application.AppmacOS / Linux:
fx="/path/to/javafx-sdk-17/lib"
javac --release 17 -encoding UTF-8 --module-path "$fx" --add-modules javafx.controls,javafx.fxml -d build/gui -sourcepath H-CLUS_Estensione/Client/src H-CLUS_Estensione/Client/src/application/App.java H-CLUS_Estensione/Client/src/application/Welcome.java H-CLUS_Estensione/Client/src/application/Avvia.java H-CLUS_Estensione/Client/src/application/Program.java
java --module-path "$fx" --add-modules javafx.controls,javafx.fxml -cp "build/gui:H-CLUS_Estensione/Client/src" application.AppThe FXML files are kept in the source folder, which is included in the runtime classpath. Some layouts were created with JavaFX 22, so JavaFX 17 may show a version warning.
- Connect to the running server (in the GUI, use the connection button).
- Enter
exampleTabas the table name. - Select Apprendi Dendrogramma da Database (learn a dendrogram from the database).
- Enter a depth of
5and choose Single-link or Average-link. - Read the clusters at each level.
- Save the result as
example.ser. The file is stored on the server, in its working directory when using a relative path. - To load it again, select the same dataset, choose Carica Dendrogramma da File and enter
example.ser.
With the five sample data points and a depth of five, the hierarchy starts with five separate clusters and ends with one cluster.
See the UML folder for the original class and package diagrams.
This is an educational project from 2024, not a production service. Run it only on a trusted local machine/network; do not expose the server to the internet or load untrusted serialized files. The Java code is preserved from the coursework, including original tutor credits. The database setup and project documentation have been adapted for GitHub.
The server and command-line client have been compiled with Java 17 compatibility. Both clustering methods and saving/loading a dendrogram were checked using the built-in sample data. A full MySQL and JavaFX integration test has not been performed on this cleaned repository.
