graal
graal copied to clipboard
maven java app fail with 'Error: No main manifest attribute'
I am trying to run the command:
native-image -jar app.jar --no-fallback
but it fail with "Error: No main manifest attribute error."
This is a maven project which is running properly in JVM, and of course it does have public static void main method as well. I was not able to find a solution. What is missing?
(graalvm-jdk-17.0.10+11.1)
This typically happens when the JAR's manifest does not specify the Main-Class attribute or when the attribute is incorrectly set. Here are some steps to troubleshoot and potentially resolve the issue:
- Ensure that your JAR file's manifest contains a Main-Class attribute that specifies the fully qualified name of your main class.
- Since this is a Maven project, make sure your pom.xml is configured to correctly package the JAR with the main class specified.
After ensuring your pom.xml is correctly configured, rebuild and repackage your project, and try the native image command again.
We can reverse the direction: Create a new maven java app in netbeans. Try to run native-image on it. It will fail with the error above.
So in short, everything is in place. There is no missing main class or wrong .pom file here.