Failed to load main class manifest attribute.

I get the following error while executing a compiled jar file. I installed my Java, but my problem has not yet been resolved.

Failed to load Main-class Manifest Attribute from D:\Tools\Lodable_Creation\dist\Lodable_Creation.jar 

The MANIFEST.MF file currently looks like.

 Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.1 Created-By: 1.6.0-b105 (Sun Microsystems Inc.) Main-Class: main X-COMMENT: Main-Class will be added automatically by build 

I am using NetBeans 6.9.1 IDE.

+4
source share
3 answers

Use the package for your class. Make sure your class looks something like this (note the package and the public class):

 package com.foo; public class Main { public static void main(String[] args) { } } 

After that, you can specify the Main-Class as follows:

 Main-Class: com.foo.Main 
+3
source

As adarshr suggested, the JVM cannot find the class because it requires a fully qualified name in the Main-Class attribute of the Manifest file.

In fact, there is no need to specify the main file. You can simply specify your JAR file as your classpath and give the full name of the class to run it with java.

Say your JAR is myJar.jar and the full main file is com.user.Main. Then from the command line go to the directory with your JAR file and give: -

 java -classpath myJar.jar com.user.Main 

And this will launch the main class. You also need to specify classes (or JARs) in the classpath that are used (imported) in your main class.

See this link for more details.

+2
source

I came across this error when I had projects with JDK (1.7 in my case) and the installed JRE was an older version (1.6). Try updating the JRE or changing the JDK, if possible, according to your version of the JRE.

0
source

Source: https://habr.com/ru/post/1398564/


All Articles