I am using a rather simple Java application that receives an input file, process it and generate an output file. I am using Picocli
for arguments to the application and Graalvm
to create a native binary.
I first created the artifact
in intellij including the libraries and specifying the class containing the main method, I then used build artifact
option to build the jar file. After that, I used the following command to create the binary
native-image -jar metadata-processor.jar
The jar and binary are created inside the project as projectName/out/artifacts/app_jar
I can run the binary using
./binary -i abc -o xyz
I can run the jar file using
java -jar binary.jar -i abc -o xyz
However when I move the binary
to ~Download
directory and run the same above command I get the error
./binary -i abc -o xyz
Error: Could not find or load main class Main
The jar is still working though i.e.
java -jar binary.jar -i abc -o xyz
If I create a simple hello world program and create a binary then it works fine even if I move it to another folder so it seems to be a library issue or project structure.
Please let me know if some special step is required in the case of libraries.