Is there a way to run a -.jar file (created with javaFx) without displaying anything(GUI, progressbar, ...)?

EmS :

I wrote a java file including javaFX. Now, I want to run this file, like java -jar example.jar But I'd like to suppress the graphical output. Is there any possible, like a flag or anything else, to do this? My program normally shows a progressbar and after that a video of the simulation.

Thanks a lot.

Abra :

To elaborate on JB Nizet's comment. JAR files have manifests. In order to run your JAR using the command java -jar example.jar, the manifest must have a Main-Class entry. And your main class must have a main() method.

So launch your app like so...

java -jar example.jar NO_GUI

And in your main() method, write something like the following...

public static void main(String[] args) {
    if (args.length > 0  &&  "NO_GUI".equals(args[0]) {
        // Don't show GUI
    }
    else {
        // Show the GUI.
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=86427&siteId=1