A Java library and CLI tool for measuring internet bandwidth using speedtest.net.
This is a lightweight Java-based implementation inspired by Matt Martz’s speedtest-cli.
- Perform download, upload, and latency tests
- (Auto-) Select best server based on ping
- Share result as a Speedtest.net image
- Use as a CLI or embed as a Java library
- Java 17+
- Maven
To build the project and create a JAR file:
mvn clean installThe JAR will be located in target/, e.g.:
target/simple-speedtest-client-3.0.0.jarTo run the CLI client:
java -jar simple-speedtest-client-3.0.0.jarusage: Optional parameters:
-h,--dedicatedServerHost <HOST> Dedicated server host to run the tests
against
-l,--listServerHosts Provide a list of server hosts to run
the tests against
-nd,--noDownload Do not perform download test
-nu,--noUpload Do not perform upload test
-of,--outputFormat <FORMAT> Output format of results (default:
console)
Available formats:
console — human-readable output to the
console
json — machine-readable JSON format
xml — machine-readable XML format
csv — comma-separated values format
-s,--share Generate and provide an URL to the
speedtest.net share results image
$ java -jar simple-speedtest-client-3.0.0.jar
Retrieving speedtest.net configuration...
Testing from Telekom Austria (193.81.52.87, AT)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by COSYS DATA GmbH (Vienna, AT) [9,46 km]: 18,00 ms
Testing download speed........................................
Download: 54,26 Mbits/s
Testing upload speed...................................................
Upload: 19,19 Mbits/sUse the library directly in Java:
try {
// ⚠️ Note: This is a blocking call and may take up to 25 seconds
// depending on network latency, server selection, and transfer speed.
// Consider running it in a background thread if used in a GUI or server application.
SpeedtestResult result = SpeedtestController.runSpeedTest();
System.out.printf("Download: %.2f Mbps%n", result.getDownload().getRateInMbps());
System.out.printf("Upload: %.2f Mbps%n", result.getUpload().getRateInMbps());
System.out.printf("Latency: %.2f ms%n", result.getLatency().getLatency());
System.out.printf("Server: %s (%s, %s)%n",
result.getServer().getSponsor(),
result.getServer().getCity(),
result.getServer().getIsoAlpha2CountryCode());
} catch (SpeedtestException e) {
e.printStackTrace();
}Download: 156,19 Mbps
Upload: 16,33 Mbps
Latency: 21,33 ms
Server: Timewarp IT Consulting GmbH (Vienna, AT)Add the dependency via JitPack: https://jitpack.io/private#BernhardAngerer/simple-speedtest-client/3.0.0