How-to articles, tricks, and solutions about JAR

Can't execute jar- file: "no main manifest attribute"

The "no main manifest attribute" error is usually caused by a missing or incorrect Main-Class attribute in the manifest file of a Java .jar file.

Eclipse "Error: Could not find or load main class"

If you are seeing an error message that says "Error: Could not find or load main class", it is likely that there is a problem with the classpath for your project.

Eclipse error: "The import XXX cannot be resolved"

If you get the error "The import XXX cannot be resolved" in Eclipse, it means that the class or package that you are trying to import cannot be found in the classpath of your project.

Extract source code from .jar file

To extract the source code from a .jar file, you can use a decompiler such as JD-GUI or Cavaj Java Decompiler.

How can I edit a .jar file?

A .jar file is a Java Archive file that contains compiled Java code and resources (such as images, sounds, etc.) that can be used by Java applications.

How to build JARs from IntelliJ properly?

To build a JAR (Java Archive) file from IntelliJ IDEA, you need to follow these steps:

How to decompile a whole Jar file?

To decompile a JAR file, you can use a Java decompiler such as JD-GUI.

How to get the path of a running JAR file?

To get the path of a running JAR file, you can use the java.lang.Class class's getProtectionDomain method and then the getCodeSource method.

How to import a jar in Eclipse?

To import a JAR file into Eclipse, follow these steps:

How to open/run .jar file (double-click not working)?

To open a .jar file on a Windows system, you can do one of the following:

How to run a JAR file

To run a JAR file, you need to have Java installed on your computer. If you don't have it installed, you can download it from the Oracle website.

Including dependencies in a jar with Maven

To include dependencies in a JAR file with Maven, you can use the maven-assembly-plugin to create an assembly that includes all the dependencies of your project.

Running JAR file on Windows

To run a JAR file on Windows, you will need to have the Java Runtime Environment (JRE) installed on your system. You can then run the JAR file by double-clicking it or by using the java command in the command prompt.

Viewing contents of a .jar file

To view the contents of a .jar file, you can use the jar command-line utility that is included with the Java Development Kit (JDK).