I have created a JavaFX
project and am able to run it with the command
java -classpath [very-long-list-of-class-paths] danIDE.Main
However, when I try to use javapackager
to create a jar out of it and run with java -jar out.jar
, the prompt says Error: Could not find or load main class danIDE.Main
The command I used to create the jar is
javapackager -createjar -v -classpath [very-long-list-of-class-paths] -srcdir src -outfile out -appclass danIDE.Main
I have googled for a long time on this problem and I still couldn't find the solution. Can someone point me to the right direction? Thanks a lot!
Edit: Here is the project structure.
and here is the exploded jar.
New exploded jar as @Garry requested:
Since you're using IntelliJ IDEA I suggest you let IDEA create your JAR file for you.
First, open up the module settings window:
Then, add a new artifact:
Select JAR From modules with dependencies:
Select your main class in the window and decide if you want to repackage all classes from your dependency JARs in your JAR (extract to target JAR option) or if you want to distribute them alongside your JAR (copy to the output directory and link via manifest option):
If you want to build it whenever you build the project (probably a good idea), click the checkbox for that:
When you next Make the project, the JAR will show up under out/artifacts:
If you didn't click the checkbox for building the JAR when you build the project you can build the JAR from the Build Artifacts option in the Build menu.
Can you try using below command? Make sure to update 'classes' folder to the Base directory of the files to package.
As you said in question that you are able to run danIDE.Main
so I assume all the required classes are available in dist folder.
So create a folder out
in the project parallel to dist
javapackager -createjar -classpath [very-long-list-of-class-paths] -appclass danIDE.Main -srcdir dist -outdir out -outfile out.jar -v
Updated: as per the uploaded screenshot: point -srcdir
to dist
, now the generated jar out.jar
will be placed in out/out.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With