Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.jline:jline3:jline-3.28.0'
}
dependencies {
implementation("com.github.jline:jline3:jline-3.28.0")
}
<dependency>
<groupId>com.github.jline</groupId>
<artifactId>jline3</artifactId>
<version>jline-3.28.0</version>
</dependency>
libraryDependencies += "com.github.jline" % "jline3" % "jline-3.28.0"
:dependencies [[com.github.jline/jline3 "jline-3.28.0"]]
JLine is a Java library for handling console input. It's similar to GNU Readline but with a focus on portability, flexibility, and integration with Java applications. See https://jline.org for its documentation.
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>3.30.0</version>
</dependency>
implementation 'org.jline:jline:3.30.0'
Here's a simple example to get you started:
import org.jline.reader.*;
import org.jline.reader.impl.*;
import org.jline.terminal.*;
import org.jline.terminal.impl.*;
public class HelloJLine {
public static void main(String[] args) {
try {
// Create a terminal
Terminal terminal = TerminalBuilder.builder()
.system(true)
.build();
// Create line reader
LineReader reader = LineReaderBuilder.builder()
.terminal(terminal)
.build();
// Prompt and read input
String line = reader.readLine("JLine > ");
// Print the result
System.out.println("You entered: " + line);
} catch (Exception e) {
e.printStackTrace();
}
}
}
JLine is organized into several modules:
JLine is licensed under the BSD License.
Contributions are welcome! Please feel free to submit a Pull Request.