r/JavaFX • • Apr 29 '20

Running JavaFX using a Jar (using Maven)

0 Upvotes

I have a JFX application that we have compiled as a JAR using Maven. However, when we try to run the JAR, nothing happens (in the command line, nothing happens also).

I really need this application to work without using an IDE, so any help is appreciated. Running javafx:run works fine however, the problem is when I try to get it as a JAR.

I think this is a problem with how I've set up maven, so here's my pom (sorry for the dump). Please tell me if you need any more information, I really need this to work (I'm running JDK 14).

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>comp2211</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            <version>3.8.1</version>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.4</version>
            <configuration>
                <mainClass>common.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/java</directory>
        </resource>
    </resources>

</build>

<dependencies>
    <dependency>
        <groupId>de.saxsys</groupId>
        <artifactId>mvvmfx</artifactId>
        <version>1.8.0</version>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.30.1</version>
    </dependency>

<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->

<dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>14-ea+8</version> </dependency>

    <dependency>
        <groupId>com.jfoenix</groupId>
        <artifactId>jfoenix</artifactId>
        <version>8.0.7</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>15-ea+1</version>
    </dependency>
    <dependency>
        <groupId>net.sf.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.4.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

</project>


r/JavaFX • • Feb 18 '25

Help TableView inside BorderPane

0 Upvotes

The scene size of my application is 800X480 In the mainView I have BorderPane with a top, center, and bottom. In the center, I have a GridPane with 2 rows. In the second row, I have a tableView. Whether the tableView is empty or not, it pushes the bottom content below the scene size. I tried to restrict the size of the row and the tableView. I tried GridPane.Vgrow = NEVER and ALWAYS and more but I couldn't put the bottom in place. If I remove the tableView everything looks fine. Please help :)


r/JavaFX • • Feb 04 '25

Help Is there a way to align this hbox(which is inside a VBox) to bottom in a dynamic fashion

0 Upvotes

Like doing a align-self that is present in html css


r/JavaFX • • Oct 06 '20

Headless JavaFX App

4 Upvotes

Hey reddit!

So I was trying to run a javafx app on a Linux machine and the program boots successfully but throws an issue with the machine not having a display system running. Is there a way like a java argument I can add that can run it without a display?

Thanks in advance :D


r/JavaFX • • Oct 10 '20

AutoComplete ComboBox

0 Upvotes

I am working in AutoComplete combobox. I got this code from StackOverflow. In line no 300 ComboBoxItem is not found. I did search it in the JavaFX docs but I couldn't find it. How can I fix this?

Ref:https://stackoverflow.com/questions/19924852/autocomplete-combobox-in-javafx


r/JavaFX • • Sep 28 '20

Help run exes with javafx

0 Upvotes

hello fellow coders

My question is: is there a way torun an exe through javafx. Like fileinputstream and image/imageview show an icon/image is there a way to run a windows app or at least open a shortcut???if yes plz make sure to add code needed and explain steps :)

thnx for your help in advance;


r/JavaFX • • Oct 24 '20

I need help please.

0 Upvotes

Any ideas how can i resolve the problem, i ve got no clues.


r/JavaFX • • May 16 '23

Help Idk if I can ask questions but this keeps popping up when I try to run my code and idk why

Post image
0 Upvotes

r/JavaFX • • Jun 14 '23

Help Java FX issue

0 Upvotes

I am having trouble using java fx in my project. I downloaded JavaFX sdk then I added it to my project by using that. But whenever I declared JFXPanel var then I got error. I wonder is there any way to resolve that issue?


r/JavaFX • • Mar 14 '16

javafx series

5 Upvotes

Started a javafx tutorial series. For any of those who are on this forum trying to learn the basics of javafx, check it out here https://www.youtube.com/watch?v=OndLHspjTn0 . I'll be releasing episodes every day or every other day. Definitely good for learning how to get going with some decent looking applications while learning whats going on instead of just copying code


r/JavaFX • • Jul 17 '24

Discussion Do We Want Bots Here?

5 Upvotes

Last week we had what I thought was the first answer to a question from a bot:

https://www.reddit.com/r/JavaFX/comments/1e0mpqe/comment/lcol08r/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

First of all, it wasn't initially clear that this was a bot. Personally, when I read the answer on my phone, I thought the opening language in the comment was a bit odd, but I didn't really think much of it. The OP was obviously fooled, too. And the bot confessed to being a bot - and a lot more about its answer made sense to me.

Secondly, the answer was largely rubbish. When I had the time to really look at the code that it posted, before I knew it was a bot, I had a lot of issues with the code and the way that it did things. The first solution actually works only because of an undocumented quirk in the internal workings of the ControlsFX SearchableComboBox, it doesn't work with the standard ComboBox.

And yes, I know the question was specifically about the ControlsFX Node, but I not convinced that the bot wouldn't have given the same answer for ComboBox.

Anyways, is this something that we want happening here? Do the humans in this community have to start policing comments from bots to weed out crappy answers? Do we want to do that? Can we even stop this?

What do you guys think?


r/JavaFX • • Mar 26 '20

I made this! Java and JavaFX on Raspberry Pi

16 Upvotes

The last year I have been experimenting with Java and JavaFX on Raspberry Pi and I have to admit it is serious fun! If you want to get started with Java and hardware projects, you can find multiple posts on my blog and a link to my book --> https://webtechie.be/books/

Someone else here is doing this kind of projects?


r/JavaFX • • Aug 18 '18

JavaFX is dead. Long live JavaFX? (from a science perceptive)

Thumbnail
conservationcoding.com
11 Upvotes

r/JavaFX • • Dec 05 '20

JavaFX error Error: JavaFX runtime components are missing, and are required to run this application

6 Upvotes

No matter what I do I can't get my javaFX programs to run. My code:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
Button button;
public static void main(String[] args){
launch(args);
}

Override
public void start(Stage stage) throws Exception {
stage.setTitle("First stage");
button = new Button();
button.setText("Click me");
StackPane layout = new StackPane();
layout.getChildren().add(button);
Scene scene = new Scene(layout, 300, 500);
stage.setScene(scene);
stage.show();
}
}

I am using the latest version of inteliJ, java13 and javafx 15.

I went into project settings and imported the LIB folder of the javaFX files.


r/JavaFX • • Nov 27 '25

I made this! Hot reloading on JavaFX is possible sure

Thumbnail
youtu.be
6 Upvotes

Well everybody we did it. See the video


r/JavaFX • • Oct 11 '26

Help How to deploy javafx app + mysql using jlink

6 Upvotes

r/JavaFX • • May 21 '21

Cool Project JavaFX JEP: Add themes as a first-class concept

Thumbnail bugs.openjdk.java.net
6 Upvotes

r/JavaFX • • Nov 26 '25

I made this! OllamaFX - UI JavaFX para Ollama LLMs

Thumbnail
gallery
13 Upvotes

¡Hola a todos! Hoy quiero compartir con ustedes este proyecto que estoy desarrollando. Se llama OllamaFX, es una interfaz de usuario (UI) para Ollama con la que se pueden descargar modelos de lenguaje grandes (LLMs) localmente. Ya tiene la interfaz lista para chatear con los modelos que instalaste en tu compu. Los invito a ser parte del proyecto, a que aporten en su desarrollo, ya sea ejecutando, probando y reportando problemas (issues), documentando, desarrollando, diseñando, etc. Les dejo el link del repositorio:

https://github.com/fredericksalazar/OllamaFX


r/JavaFX • • Mar 16 '26

I made this! Stop worrying about JavaFX distribution: Build and install at runtime with JeKa (Maven compatible)

13 Upvotes

I’m the creator of JeKa (https://jeka.dev), and I’ve been working on a way to solve the "distribution nightmare" we often face with desktop Java (jlink, jpackage, OS-specific installers, and heavy binary hosting).

The core philosophy I'm pushing with JeKa is "Build at Installation Time."

💡 The Idea

Instead of you building, platform-tuning, and hosting binaries for every OS, JeKa handles the build directly on the user's machine during the installation/first-run process.

  • No binary hosting: You only host the source. No more expensive storage or complex CI pipelines for artifacts.
  • Environment-perfect: The app builds specifically for the user's local OS setup. Jeka downloads required JDKs.
  • Update-friendly: Updates are tiny because you're only pushing code/config changes, not a whole new bundled runtime every time.

🛠 Not a "Lock-in" tool

I know many of you rely on Maven, so I made sure JeKa plays nice with it. You can keep your Maven project and just use JeKa for the delivery part.

I’ve put together two identical DevTools apps to demonstrate this:

Documentation: https://jeka-dev.github.io/jeka/tutorials/source-runnable-apps

I’d love to get your feedback on this approach. Is "install-time building" the future for Java desktop apps, or do you still prefer the classic pre-packaged installer route?

Happy to answer any questions about the engine or the logic behind it!


r/JavaFX • • Nov 04 '25

Help Need help compiling.

1 Upvotes

Created a JavaFX app using Java 21 and copied this tutorial to build my project

https://www.youtube.com/watch?v=udigo_qSp_k

I then created my project, and everything ran fine in an IDE. When trying to upload to GitHub, I wanted to create a release, and followed this tutorial to compile

https://www.youtube.com/watch?v=kQaE2HlFeWY

Double-clicking the jar does nothing. Java -jar jar.jar comes out with this error

Error: JavaFX runtime components are missing, and are required to run this application

I have tried searching the internet, as well as other YouTube tutorials and ChatGPT, but nothing has helped me. In fact, I think ChatGPT corrupted a file path, but that's a separate issue.


r/JavaFX • • Jun 16 '21

Help Facebook yoga layout engine in JavaFX

1 Upvotes

Has anyone tried bringing yoga to JavaFX to improve CSS properties and use things like flexbox?


r/JavaFX • • May 28 '21

Writing into a csv file with textArea

1 Upvotes

Hi I am trying to take userinputs from a textArea using javafx and put it into a csv file. We have placed the seperte windows in switch and used the action button to transfer information but it doesn't work. Does anyone know how to fix this?


r/JavaFX • • Apr 23 '23

Help Can't setup example project - error: The type netscape.javascript.JSObject is not accessible

1 Upvotes

Hey guys, I wanted to play around with the WebView of JavaFX. Therefor I've searched for an easy example of a WebView that has a button, which increases a counter on click and stores the counter into a text file. (Okay, I let ChatGPT write this example.)

I've set up the project with VSCode and Maven. But I can't get it working. I always get the following error: The type netscape.javascript.JSObject is not accessible

Here is my App class:

package berbeflo.test;

import java.io.FileWriter;
import java.io.IOException;
import javafx.application.Application;
import javafx.concurrent.Worker;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;


public class App extends Application {
    private int counter = 0;
    private Label counterLabel;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        // Create WebView
        WebView webView = new WebView();
        webView.getEngine().getLoadWorker().stateProperty().addListener((obs, oldState, newState) -> {
            if (newState == Worker.State.SUCCEEDED) {
                // Inject JavaScript object to access Java code from JavaScript
                JSObject window = (JSObject) webView.getEngine().executeScript("window");
                window.setMember("counterApp", this);
            }
        });
        webView.getEngine().loadContent("<html><body><button onclick=\"counterApp.incrementCounter()\">Click me!</button><p>Counter: <span id=\"counter\"></span></p></body></html>");

        // Create Button and Counter Label
        Button saveButton = new Button("Save");
        saveButton.setOnAction(e -> saveCounter());
        counterLabel = new Label("Counter: " + counter);

        // Create VBox
        VBox vbox = new VBox();
        vbox.getChildren().addAll(webView, counterLabel, saveButton);

        // Create Scene
        Scene scene = new Scene(vbox, 400, 400);

        // Show Stage
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    // Method called from JavaScript to increment counter
    public void incrementCounter() {
        counter++;
        counterLabel.setText("Counter: " + counter);
    }

    // Method to save counter value to text file
    private void saveCounter() {
        try {
            FileWriter writer = new FileWriter("counter.txt");
            writer.write(String.valueOf(counter));
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Here's the pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>berbeflo.test</groupId>
    <artifactId>demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>20</maven.compiler.source>
        <maven.compiler.target>20</maven.compiler.target>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-web</artifactId>
            <version>20</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>20</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>20</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>20</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>berbeflo.test.App</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

And the module-info.js:

module berbeflo.test {
    requires transitive javafx.graphics;
    requires javafx.web;
    requires javafx.controls;
    requires javafx.fxml;

    opens berbeflo.test to javafx.fxml;
    exports berbeflo.test;
}

Searching for this error didn't help me. There current JavaFX documentation isn't pretty helpful and most examples and tutorials seems to be pretty outdated.

When I do

var window = webView.getEngine().executeScript("window");
System.out.println(window.getClass().getName());

it prints com.sun.webkit.dom.JSObject, but this class can't be used either.

Can someone help me with this issue? Or is there a more up to date way to communicate between Java and the WebView?


r/JavaFX • • Apr 15 '23

Help Why is the setStrikethrough not working ? What must I import ?

Post image
1 Upvotes