0

I am making JavaFX application as a university assignment and I want to include a .exe file of the application. However, while trying to build the application gradlew run I ran into java.lang.UnsupportedClassVersionError. My build.gradle:

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


version '1.0-SNAPSHOT'


repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

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

run{
    standardInput = System.in
    standardOutput = System.out
}

jar {
    from {
        configurations.runtime.collect {
            it.isDirectory() ? it : zipTree(it)
        }
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
    manifest {
        attributes 'Main-Class': 'java.frontend.Main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

mainClassName = 'frontend.Main'

project structure

If I try to use grade -> build -> build and run the build/libs/"the built file" I have two errors:

Error: Could not find or load main class java.frontend.Main
Caused by: java.lang.ClassNotFoundException: java.frontend.Main
  • What is the full output of `./gradlew --version`? – Slaw Jun 16 '20 at 06:28
  • ------------------------------------------------------------ Gradle 5.2.1 ------------------------------------------------------------ Build time: 2019-02-08 19:00:10 UTC Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183 Kotlin DSL: 1.1.3 Kotlin: 1.3.20 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018 JVM: 1.8.0_241 (Oracle Corporation 25.241-b07) OS: Windows 10 10.0 x86 – Evgeni Genchev Jun 16 '20 at 20:36
  • There's your problem. Gradle is using Java 1.8.0_241 but JavaFX 13 requires at least Java 11. You seem to be using an Oracle distribution anyway, which means JavaFX 8 should be included in the JDK. Why not just use that? – Slaw Jun 16 '20 at 21:04
  • it throws exception : Execution failed for task ':compileJava'. > Could not resolve all files for configuration ':compileClasspath'. – Evgeni Genchev Jun 16 '20 at 23:14
  • See if any of the many answers to [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929) help you. – Slaw Jun 17 '20 at 04:03
  • They do not unfortunately – Evgeni Genchev Jun 17 '20 at 14:07
  • Then I'm not sure how to help. The solution is to either upgrade Java or, if your Java distribution includes JavaFX, stop trying to pull in JavaFX as a dependency. – Slaw Jun 17 '20 at 16:48

0 Answers0