graal icon indicating copy to clipboard operation
graal copied to clipboard

maven java app fail with 'Error: No main manifest attribute'

Open bncdemo opened this issue 1 year ago • 2 comments

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)

bncdemo avatar Feb 08 '24 20:02 bncdemo

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.

fernando-valdez avatar Feb 09 '24 03:02 fernando-valdez

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.

bncdemo avatar Feb 09 '24 08:02 bncdemo