Jump to content

Javafx Integration (Copy but now in correct topic)


Recommended Posts


I am currently trying to implement Javafx into a minecraft mod. For testing purposes all I am trying to do is make the javafx web browser system open on top of minecraft in the window. I have the code correct as it will work on its own, but as soon as I add it to Minecraft the client loads but then greets me with Caused by: java.lang.ClassNotFoundException: javafx.application.Application. I attached my Build.Gradle, main mod class, and the web browser (main app) class.


plugins {
    id 'eclipse'
    id 'idea'
    id 'maven-publish'
    id 'net.minecraftforge.gradle' version '[6.0,6.2)'
    id 'org.parchmentmc.librarian.forgegradle' version '1.+'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.9'

javafx {
    version = "16"
    modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web' ]

version = mod_version
group = mod_group_id

base {
    archivesName = mod_id

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"

minecraft {
    mappings channel: mapping_channel, version: mapping_version

    copyIdeResources = true

    runs {
        configureEach {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            mods {
                "${mod_id}" {
                    source sourceSets.main

        client {
            property 'forge.enabledGameTestNamespaces', mod_id

        server {
            property 'forge.enabledGameTestNamespaces', mod_id
            args '--nogui'

        gameTestServer {
            property 'forge.enabledGameTestNamespaces', mod_id

        data {
            workingDirectory project.file('run-data')
            args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {

dependencies {
    minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
    implementation 'org.openjfx:javafx-controls:16'
    implementation 'org.openjfx:javafx-fxml:16'
    implementation 'org.openjfx:javafx-web:16'

jar {
    from {
        configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) }

mainClassName = 'net.chydog.webuimod.MainApp'

tasks.named('processResources', ProcessResources).configure {
    var replaceProperties = [
            minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
            forge_version: forge_version, forge_version_range: forge_version_range,
            loader_version_range: loader_version_range,
            mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
            mod_authors: mod_authors, mod_description: mod_description,
    inputs.properties replaceProperties

    filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
        expand replaceProperties + [project: project]

tasks.named('jar', Jar).configure {
    manifest {
                'Specification-Title'     : mod_id,
                'Specification-Vendor'    : mod_authors,
                'Specification-Version'   : '1', // We are version 1 of ourselves
                'Implementation-Title'    : project.name,
                'Implementation-Version'  : project.jar.archiveVersion,
                'Implementation-Vendor'   : mod_authors,
                'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
package net.chydog.webuimod;

import com.mojang.logging.LogUtils;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import javafx.application.Application;

import static net.chydog.webuimod.WebUiMod.ClientModEvents.launchJavaFXApplication;

// The value here should match an entry in the META-INF/mods.toml file
public class WebUiMod {
    // Define mod id in a common place for everything to reference
    public static final String MODID = "webuimod";
    // Directly reference a slf4j logger
    private static final Logger LOGGER = LogUtils.getLogger();

    public WebUiMod() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();



        // Register the item to a creative tab
        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);

    private void commonSetup(final FMLCommonSetupEvent event) {
        // Launch your JavaFX application when Minecraft initializes

    // Add the example block item to the building blocks tab
    private void addCreative(BuildCreativeModeTabContentsEvent event) {


    // You can use SubscribeEvent and let the Event Bus discover methods to call
    public void onServerStarting(ServerStartingEvent event) {


    // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
    @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
    public static class ClientModEvents {
        public static void onClientSetup(FMLClientSetupEvent event) {


        static void launchJavaFXApplication() {
            // Launch your JavaFX application here
package net.chydog.webuimod;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class MainApp extends Application {

    public void start(Stage stage) throws Exception {
        WebView webView = new WebView();
        webView.getEngine().load("https://www.abcya.com"); // Set your desired URL here

        Scene scene = new Scene(webView, 800, 600);

        stage.setTitle("Web Browser");

    public static void main(String[] args) {


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.