-1

I created artifacts and when starting the program I get the error Class com.abstudio.fakture.MainActivity not found. When I run a program through the IDE it does everything right.

IDE: Intelij IDEA JavaFX Java 8

Manifest file:

Manifest-Version: 1.0
Main-Class: com.abstudio.fakture.MainActivity

MainActivity is in path: src/main/java/com/abstudio/fakture/MainActivity

When in cmd I run the command "jar tf ePDV.jar" i see that the com/abstudio/fakture/MainActivity path is compiled with other classes, interfaces, etc.

My build.gradle file:

plugins {
    id 'java'
    id 'application'
    id 'idea'
}
sourceCompatibility = JavaVersion.VERSION_1_8
group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}
jar {
    manifest {
        attributes(
                'Main-Class': 'com.abstudio.fakture.MainActivity'
        )
    }
}
sourceSets.main {
    java {
        srcDir 'src/main/java' //assume that your source codes are inside this path
    }
    resources {
        srcDirs = ['src/main/java', 'src/main/resources']
        exclude "**/*.java"
    }
}


dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.jfoenix:jfoenix:8.0.10'
    implementation group: 'de.jensd', name: 'fontawesomefx', version: '8.1'
    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.22'
    // https://mvnrepository.com/artifact/com.itextpdf/itextpdf
    implementation group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13.2'

    implementation group: 'org.apache.derby', name: 'derby', version: '10.14.1.0'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
    implementation group: 'org.controlsfx', name: 'controlsfx', version: '8.40.18'

    implementation 'org.apache.commons:commons-configuration2:2.7'
    implementation 'commons-io:commons-io:2.11.0'
    implementation 'commons-net:commons-net:3.8.0'



}
mainClassName = 'com.abstudio.fakture.MainActivity'

In project structures Application class is com.abstudio.fakture.MainActivity

Artifacts and manifest

Artifacts JavaFX

Compiled classes

How to solve this problem? Thanks

1 Answers1

0

One way to address this is to simply start over from scratch using an alternate method.

This is not an easy task, but will probably give a decent outcome if you can manage it:

  1. Create a new JavaFX project using the IDE.
  2. Use recent software, JDK 17.0.2 and JavaFX 17.0.2 and jfoenix 9, font awesomefx 9, as well as up-to-date versions of other software.
  3. Use Maven to build the project instead of Gradle, because it is easier unless you really know what you are doing.
  4. Copy your existing code into the project created by the wizard and reimport the updated maven pom to get all the dependencies synchronized.
  5. Update module-info.Java file to define your app module requirements,
  6. The latest versions of most of the libraries you defined will be modular and linkable, ones that are not you will need to patch to add module info.
  7. If it is too difficult to get modularity working, delete the module-info and follow instructions at JPackageScriptFX.
  8. Test and debug until it works.
  9. Do not create a fat jar that includes JavaFX.
  10. Use a jlink zip format via the openjfx-maven-plugin or use jpackage to package the app using JPackageScriptFX.

Because you are sharing similar libraries, also see:

Which has info on the library versions to use and recommended dev approach (a lot of the info in the answer is relevant to you, regardless of whether you use SceneBuilder on not).

jewelsea
  • 150,031
  • 14
  • 366
  • 406