I am making a simple Telegram bot with my own custom library in JavaFX with OpenJDK 11. The project was built as a JavaFX project from IntelliJ IDEA, with Gradle as build system. The library consists of a single class (Telegram) with a single function to send a message, and uses the JTeleBot library (https://github.com/shibme/jtelebot). I do NOT have JavaFX installed, I am instead using the IntelliJ default JavaFX libraries, which has been working fine until now for previous projects. The program opens properly before including the custom library, but as soon as I include it, it gives the following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module Telegram not found, required by my.group.project_telegram
Does anybody have any idea on how to fix this? require Telegram
is included in the module-info.java
file. I have also tried remaking the project from scratch, with no results. Here are some of my project files:
build.gradle:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.1'
}
group 'my.group'
version '1.0'
repositories {
mavenCentral()
maven {
url "https://gitlab.com/api/v4/projects/<project-id>/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = gitLabPrivateToken // the variable resides in ~/.gradle/gradle.properties
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
ext {
junitVersion = '5.8.2'
}
sourceCompatibility = '11'
targetCompatibility = '11'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'my.group.project_telegram'
mainClass = 'my.group.project_telegram.HelloApplication'
}
javafx {
version = '11.0.2'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
implementation('my.group:Telegram:1.0')
implementation('org.controlsfx:controlsfx:11.1.1')
implementation('com.dlsc.formsfx:formsfx-core:11.5.0') {
exclude(group: 'org.openjfx')
}
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip") as RegularFile
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
module-info.java:
module my.group.project_telegram {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
requires com.dlsc.formsfx;
requires Telegram;
opens my.group.project_telegram to javafx.fxml;
exports my.group.project_telegram;
}
The library:
package pkgTelegram;
import me.shib.java.lib.telegram.bot.service.TelegramBot;
import me.shib.java.lib.telegram.bot.types.*;
import java.io.IOException;
public class Telegram {
public static void sendToTelegram(String apiToken, String chatId, String text) {
// the function's code
}
}