1

I build my project using gradle jar command, then try to start my application using command java -jar MyProject.jar

After that I have error:

Error: Could not find or load main class org.apdalgo.Main<br> Caused by: java.lang.NoClassDefFoundError: javafx/application/Application 

My build.gardle:

 plugins { id 'java' id 'application' id 'org.openjfx.javafxplugin' version '0.0.7' } group 'org.apdalgo' version '1.0-SNAPSHOT' sourceCompatibility = 11 repositories { mavenCentral() } dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' } javafx { version = "12" modules = [ 'javafx.controls', 'javafx.fxml' ] } mainClassName = 'org.apdalgo.Main' jar { manifest { attributes 'Main-Class': 'org.apdalgo.Main', 'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ') } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } } 
1

1 Answer 1

1

The command line need a bit more see https://openjfx.io/openjfx-docs/#install-javafx

java --module-path <PATH_TO_FX> --add-modules javafx.controls

Sign up to request clarification or add additional context in comments.

1 Comment

I think that's not the problem, I created empty gradle project and try build it into jar file and it is also doesn't find main class

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.