0

The project has the following file structure: file structure

build.gradle:

...
jar {
    baseName = 'billiard-viewer'
    manifest.attributes 'Main-Class': 'billiards.viewer.Main'
    //manifest.attributes 'Main-Class': 'fake_main'
}

sourceSets {
    main {
        java {
            srcDir 'src/java'
        }
    }
}
...

And the artifact was set up as: Artifacts Setting

When I build and run the program in Intellij, it works perfectly. However, when I try to build it into a standalone JAR program, it keeps giving me Error: Could not find or load main class fake_main.

Could anyone give me some ideas about what could be the reason behind this and how I can solve it?

ZjTan4
  • 1
  • 1
  • How do you build it as a JAR? – dan1st May 06 '21 at 08:31
  • 1
    Don’t do that. Use the application plugin. – Boris the Spider May 06 '21 at 08:34
  • I use the Build->Build Artificts option in Intellij. I am pretty sure that the artifacts setting is fine, since it was quite straight forward – ZjTan4 May 06 '21 at 08:36
  • I think somebody had a similar question before Maybe check https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean – ArtificialFool May 06 '21 at 08:39
  • I don't think they are the same problem. If you look at the file structure, you will see that the main is there, under billiards/viewer. And it can run from debug mode. It doesn't work only when I try to pack it into a JAR. – ZjTan4 May 06 '21 at 17:33

0 Answers0