javawindowsjarjavapackager

Building Jar using javapackager from command


I'm trying to create a jar file using javapackager from command prompt. For that I have a simple java project. Only one class is there and inside the class a main method, which prints a message.

javapackager -createjar -appclass com.simple.Test -outdir D:/myworkspace/test/target/dist/ -outfile test -srcdir D:/myworkspace/test/src/

It creates a jar called test.jar in dist folder. But when I tried to run the jar it throws an Error saying

Could not find or load main class com.simple.Test

This is the link I'm following https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html

Can anyone help me on this? Thanks


Solution

  • From the above command I have noticed that your -srcdir is pointing to src, instead of bin. You can see there is a folder created bin which will have compiled file. -srcdir should be like this

    -srcdir D:/myworkspace/test/bin/