Class not found issue

Issue #8 on hold
Former user created an issue


I am using the plugin, and it works quite well, but when I run the jar file it produces it says it can't find my main class.

The only interesting thing I did in the build file was to change the srcDir for java source, and the buildDir for the output.

Can that cause problems?

thanks graham

Comments (10)

  1. Danno Ferrin repo owner

    Changing the builddir would have more of an impact I think than the source dir. However, I would really need a sample to say much about it intelligently.

  2. Anonymous

    Hi there. I have encountered the same problem as Anon., both on my own project and when trying to build the brickbreaker and SwingInterop samples.

    The only changes I made to the sample projects were to modify the URLs for the plugin script:

    I used the line:

    apply from: ""

    ... as recommended on

    The build process properly produces the directory build/distributions/bundles, which contains the directories "app" and "runtime", and an executable for the app. When I double-click on the executable, the runtime reports that the main class cannot be found.

    I am using Windows 32-bit Windows 7, Gradle 1.6, and JDK 1.7.0_21.

  3. Danno Ferrin repo owner

    Can you run the build with --debug and post the results somewhere like There is a known bug in Java 1.7 regarding library jars lacking manifests. The debug stack trace will let me know what the errors are.

    Without such diagnostics all I can do is nod my head and say "it could be that bug" and not be sure.

  4. Anonymous


    Got the same problem. When starting the .exe. I am using Java 1.7 build 45. My build.gradle:

    apply plugin: "java"
    apply from: 'javafx.plugin'
    javafx {
        javaRuntime = 'C:\\Program Files\\Java\\jdk1.7.0_45'
        mainClass 'sample.Main'
        embedLauncher = false
        releaseKey {
            alias = 'release'
            keyPass = "test"
            keyStore = file("keystore.jks")
            storePass = "test"
    buildscript {
        repositories {
        dependencies {
            classpath 'com.github.rholder:gradle-one-jar:1.0.3'
    repositories {
    maven {
        url ""
    dependencies {
        compile "org.springframework:spring-core:3.2.5.RELEASE"
        compile "org.springframework:spring-web:3.2.5.RELEASE"
        compile "org.springframework.hateoas:spring-hateoas:0.7.0.RELEASE"
        compile "com.fasterxml.jackson.core:jackson-core:"
        compile "com.fasterxml.jackson.core:jackson-databind:2.2.2"
        compile 'org.apache.httpcomponents:httpclient:4.3.1'
        compile "joda-time:joda-time:2.3"

    the javafx.plugin is besides the build.gradle like in the samples. I am behind a NTLM Proxy and that was on way I got the retrieve working.

    My logfile:

  5. Anonymous

    Yeah, got it working, but it hasnĀ“t something to do with this issue, has it? Was the logfile helpful?

  6. Vladimir Matveev

    Hi all,

    It looks like that jfxJar task creates a jar file which contains original jar file instead of contents of the original jar file. Java runtime does not handle nested jars, so it can't find the main class. It looks like an issue in JavaFX packager configuration.

  7. Vladimir Matveev

    Looks like I have found out the cause of this. This is what javafx-gradle plugin does when it creates parameters for JavaFX packager:

    createJarParams.addResource(null, getJarFile())

    And this is what javafx-maven-plugin does:

    createJarParams.addResource(new File(build.getOutputDirectory()), "");

    That is, Maven plugin adds class files directly from the output directly, but Gradle plugin adds final jar file to the JavaFX jar. It is incorrect.

    Franky, I think that Maven plugin behavior is better. It does not replace original jar file, it creates a new one with -jfx classifier in separate directory instead. Also it collects all dependencies into a separate directory lib instead of placing these directories along with main jar. Without this it is difficult to use Gradle plugin when you only want a jar file instead of the whole installer.

  8. Log in to comment