java-ngrok
is a Java wrapper for
ngrok
that manages its own binary, making
ngrok
available via a convenient Java API.
ngrok is a reverse proxy tool that opens secure tunnels from public URLs to localhost,
perfect for exposing local web servers, building webhook integrations, enabling SSH access, testing chatbots,
demoing from your own machine, and more, and its made even more powerful with native Java integration through
java-ngrok
.
Installation
java-ngrok
is available on
Maven Central.
Maven
<dependency>
<groupId>com.github.alexdlaird</groupId>
<artifactId>java-ngrok</artifactId>
<version>2.2.3</version>
</dependency>
Gradle
implementation "com.github.alexdlaird:java-ngrok:2.2.3"
If we want
ngrok
to be available from the command line,
pyngrok can be installed using
pip
to manage that for
us.
Getting Started
To get started using
java-ngrok
, see the docs for the
NgrokClient
.
Integration Examples
java-ngrok
is useful in any number of integrations, for instance to test locally without having to deploy
or configure. Here are some common usage examples.
ngrok
Version Compatibility
java-ngrok
is compatible with
ngrok
v2 and v3, but by default it will install v3. To install
v2 instead, set the version with
JavaNgrokConfig.Builder.withNgrokVersion(NgrokVersion)
and
CreateTunnel.Builder.withNgrokVersion(NgrokVersion)
.
Java 8
Java 8 support is not actively maintained, but a compatible build of this project does exist for Java 8. To use it,
include the
java8-ngrok
dependency from
Maven Central
instead.
<dependency>
<groupId>com.github.alexdlaird</groupId>
<artifactId>java8-ngrok</artifactId>
<version>1.4.5</version>
</dependency>
The
Process API was introduced in
Java 9, so certain convenience methods around managing the
ngrok
process (for instance, tearing it down)
are not available in the Java 8 build.