Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
If a Maven JAR built in NetBeans reports no main manifest attribute when you run it with java -jar, configure the entry point in the project’s pom.xml. Set the Maven JAR Plugin’s mainClass to the fully qualified name of your application class, then rebuild and verify the JAR. NetBeans can run a class with its own configured class path, but for a Maven project the POM controls how Maven packages the JAR.
1. Confirm this is a Maven application JAR
These steps apply to a standard Maven project packaged as a JAR. You should see a pom.xml at the project root, application source under src/main/java, and—after a build—the artifact normally under target/. If the POM specifies packaging, it should ordinarily include <packaging>jar</packaging>; JAR is Maven’s default packaging when that element is omitted.
This is not the same workflow as a traditional NetBeans Ant project, where NetBeans project properties can generate the manifest. In a Maven project, put durable packaging settings in the POM. NetBeans’ Maven guidance describes the POM-based build model; its traditional Java deployment tutorial covers the separate Ant-oriented workflow.
Free tools Windows power users keep installed
One-click scans. No signup required.
2. Find the correct main class name
The manifest’s Main-Class value is a Java class name, including its package, not a source-file path. For example, given:
package com.example.app;
public class Application {
public static void main(String[] args) {
System.out.println("Started");
}
}
the value is com.example.app.Application. Do not use Application.java, com/example/app/Application.class, or a path beneath target/classes. The class must be included in the application JAR and expose the standard public static void main(String[] args) entry point.
3. Configure the Maven JAR Plugin
Open the project’s pom.xml in NetBeans, find its existing <build> section, and add or update the plugin configuration below. If there is no <build> section, add it inside <project>.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.app.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Replace com.example.app.Application with the actual package and class name. Maven Archiver uses <archive><manifest><mainClass>...</mainClass></manifest></archive> to write the Main-Class entry. See the Maven Archiver class-path and manifest example and the Maven JAR Plugin manifest customization guide. The official example currently shows JAR Plugin version 3.5.1; select and pin a version that fits your project’s Maven and JDK requirements rather than treating any example version as permanent.
4. Rebuild in NetBeans or from a terminal
Save the POM, then run clean package as a Maven goal in NetBeans, or right-click the project and choose Clean and Build. From a terminal at the project root, run:
Rank #2
mvn clean package
The JAR Plugin’s jar:jar goal is normally bound to Maven’s package phase, so a separate manual invocation of the plugin is generally unnecessary once the POM is configured. The new artifact is normally in target/.
5. Verify the manifest and launch the JAR
Inspect the JAR Maven just built—not an older copy elsewhere. You can list its contents with:
jar tf target/your-artifact.jar
On systems with unzip, print the manifest without extracting it:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11unzip -p target/your-artifact.jar META-INF/MANIFEST.MF
Alternatively, extract the manifest with the JDK’s jar tool:
jar xf target/your-artifact.jar META-INF/MANIFEST.MF
The main section should include a line such as:
Main-Class: com.example.app.Application
Then launch the artifact using its actual filename:
java -jar target/your-artifact.jar
The Java launcher reads the Main-Class attribute from META-INF/MANIFEST.MF. A JAR can contain compiled classes without having this entry, which is why a class that runs inside the IDE may not run through java -jar.
A main class is not the same as a self-contained JAR
The configuration above identifies the application entry point. It does not copy third-party dependency classes into the JAR. If the manifest is correct but launch fails with NoClassDefFoundError or ClassNotFoundException, the entry point may be fine while a runtime dependency is missing.
Keep dependencies in a separate lib/ directory
If you distribute dependency JARs alongside the application, you can add references to them in the manifest:
Rank #4
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.app.Application</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<addClasspath>true</addClasspath> adds a manifest Class-Path entry; <classpathPrefix>lib/</classpathPrefix> prefixes the dependency paths. The referenced JARs still need to be present in the expected relative lib/ directory at launch time. This option writes references—it does not merge those libraries into the application JAR. Maven Archiver documents these settings in its class-path example.
Another option is to supply the class path explicitly, for example:
java -cp "target/app.jar:lib/*" com.example.app.Application
On Windows, use a semicolon as the class-path separator:
Recommended Free Tools
java -cp "targetapp.jar;lib*" com.example.app.Application
With java -jar, the launcher uses the JAR’s manifest and class-path information; do not expect a separate -cp argument to provide the usual alternative class path for that launch mode.
Best Value
Bundle dependencies into one distributable JAR
If you specifically need a single file containing application classes and dependencies, use a bundling plugin such as Maven Shade or Assembly, or the official Maven plugin for your framework. A Shade Plugin setup can run during package and use ManifestResourceTransformer to set the main class. Choose a plugin version supported by your project and consult its documentation for the complete configuration.
A bundled JAR is convenient to distribute, but combining dependencies can introduce resource conflicts. Service-loader files may need merging; signed dependency metadata may need filtering; and frameworks can require additional metadata handling. Modular, reflective, JavaFX, or framework-specific applications may need further configuration. A separate lib/ directory is often clearer when a single-file deliverable is not essential.
Troubleshooting when the manifest is still wrong
no main manifest attribute: The JAR being launched lacks a usableMain-Class. Check the POM, runmvn clean package, and inspect the newly built JAR’s manifest.Could not find or load main class: Check the fully qualified name, capitalization, package declaration, whether the class is present in the JAR, and whether you launched the intended artifact.Main method not found: The manifest points to a class without the expected entry-point method. Confirm the class haspublic static void main(String[] args).- NetBeans runs it, but
java -jardoes not: The IDE may launch a class directly with a class path it constructs. That does not prove the packaged JAR has aMain-Classentry or includes runtime dependencies. - The manifest does not change: Confirm you edited the POM for the project being built, that the build reaches
package, and that you are inspecting the artifact under the correcttarget/. Check whether a parent POM or active profile overrides the configuration, or another plugin creates the final artifact afterward. - The main class is absent: Ensure it is in
src/main/java, not onlysrc/test/java. Search the archive contents withjar tf target/your-artifact.jar; in PowerShell, you can filter withjar tf targetyour-artifact.jar | Select-String Application. - You need to see Maven’s merged configuration: Run
mvn help:effective-pomand check the output for the JAR Plugin andmainClass. This can reveal parent-POM or profile settings that are not obvious in the local POM. - You are using a custom manifest: Check its spelling and entries. A custom manifest is optional for the ordinary main-class case. Maven Archiver can merge a supplied manifest via
<manifestFile>, and supplied values can override generated ones; see its custom manifest documentation. Avoid editing generated files undertarget/as a permanent fix; the next build can replace them.
Special case: NetBeans Platform modules
A NetBeans Platform module is not an ordinary executable Java application JAR. Platform builds generate module-specific manifest metadata through nbm-maven-plugin; setting an application Main-Class is not a substitute. Follow the NetBeans Platform Maven quick start and the module manifest documentation. Where the generated manifest must be handed to the JAR Plugin, the documented configuration uses a manifest file from the build output directory, for example:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
This preserves the module’s generated manifest; it is different from configuring an executable application’s Main-Class.
Bottom line
For a normal NetBeans Maven JAR project, put the fully qualified entry-point class in the Maven JAR Plugin’s <mainClass> setting, run mvn clean package, and verify META-INF/MANIFEST.MF in the artifact under target/. If dependencies are missing, solve dependency packaging separately; adding a main class alone does not make a fat JAR.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

