- #1
- 2,173
- 2,716
I have three classes: Prog, CreateThread and BuildGUI. The last class has the
But I am being unable to create an executable JAR file. As you might be knowing, Apache NetBeans 11.0 no longer allows a simple Java application; instead, you must create an application with Maven, Ant or Gradle. I tried using the first, and followed several tricks from StackOverflow, but none of them worked. When I executed the JAR file from command line, it gave me an error, "No main class".
So I switched to creating the JAR file from command line itself. I put all of the three classes into one folder, and compiled them there. I removed the package statements for simplicity (earlier it was something like
Then I create a JAR file using
I can clearly see a Main-Class attribute in Manifest file. What is going wrong here? How can I share my application?
main()
method. I tested these classes using JDK 12 on NetBeans 11.0, and my program is working fine.But I am being unable to create an executable JAR file. As you might be knowing, Apache NetBeans 11.0 no longer allows a simple Java application; instead, you must create an application with Maven, Ant or Gradle. I tried using the first, and followed several tricks from StackOverflow, but none of them worked. When I executed the JAR file from command line, it gave me an error, "No main class".
So I switched to creating the JAR file from command line itself. I put all of the three classes into one folder, and compiled them there. I removed the package statements for simplicity (earlier it was something like
com.basuLabs.xyz
). I followed the answers here to some extent, and wrote down a Manifest file:
MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: BuildGUI
jar cfm myjar.jar MANIFEST.MF *.class
, and run it using java -jar myjar.jar
And I get irritated when I get the same error again and again:no main manifest attribute, in myjar.jar
I can clearly see a Main-Class attribute in Manifest file. What is going wrong here? How can I share my application?