openjfx / openjfx-docs

Getting started guide for JavaFX 11
BSD 3-Clause "New" or "Revised" License
96 stars 25 forks source link

can not start javafx project #114

Closed abdullanablsi closed 5 years ago

abdullanablsi commented 5 years ago

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

sharidass1408 commented 5 years ago

I am facing the same issue in my project after generating the Jar file using gradle.

plugins { id 'java' id 'application' id 'org.openjfx.javafxplugin' version '0.0.8' }

group 'com.ltdrive' version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories { mavenCentral() maven { url 'http://www.nexus.ford.com/repository/thirdparty' } maven { url 'https://mvnrepository.com/artifact/com.hynnet/jacob' } maven { url 'https://plugins.gradle.org/m2/' } }

dependencies { compile group: 'org.apache.poi', name: 'poi', version: '4.1.0' compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.0' compile group: 'net.sf.ucanaccess', name: 'ucanaccess', version: '4.0.4' compile group: 'com.hynnet', name: 'jacob', version: '1.18' compile group: 'commons-io', name: 'commons-io', version: '2.6' compile group: 'com.j2html', name: 'j2html', version: '1.4.0' //compile group: 'org.openjfx.javafxplugin', name: 'org.openjfx.javafxplugin.gradle.plugin', version: '0.0.8', ext: 'pom' testCompile group: 'junit', name: 'junit', version: '4.12' }

javafx { version = "13" modules = [ 'javafx.controls', 'javafx.fxml'] }

jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { attributes ( 'Implementation-Title' : 'Jar Making Example', 'Main-Class': 'javafxltdrive.JavaFxLTDrive' )

}

exclude("**/**.SF")
exclude("**/**.RSA")
exclude("**/**.DSA")

destinationDirectory = file("$rootDir/my-jar")
archivesBaseName = 'LTDrive'

}

mainClassName = 'javafxltdrive.JavaFxLTDrive'

ToORAGe commented 5 years ago

Have the same issue, using Adopt OpenJDK and OpenJFX.

jperedadnr commented 5 years ago

@sharidass1408 your jar task should use configurations.runtimeClasspath, as now the JavaFX plugin uses implementation instead of the deprecated compile (that is why configurations.compile doesn't include the JavaFX classes in the fat jar).

The docs/sample already contain this change. See for instance this build.