I have a working java program that I would like to turn into a .jar and eventually a .exe. I am using maven in VS Code on a mac. Initially, I was getting the "no main manifest attribute" error, which I resolved by adding "Main-Class: com.solace.SolaceControlCenter" to my MANIFEST.MF file through maven using this plug-in:
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>com/</classpathPrefix>
<mainClass>com.solace.SolaceControlCenter</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
This plugin also added these to my MANIFEST.MF file:
"Class-Path: com/miglayout-core-11.1.jar com/miglayout-swing-11.1.jar com /commons-compress-1.21.jar com/poi-ooxml-5.2.3.jar com/poi-ooxml-lite-5 .2.3.jar com/xmlbeans-5.1.1.jar com/commons-io-2.11.0.jar com/curvesapi -1.07.jar com/log4j-api-2.18.0.jar com/commons-collections4-4.4.jar com /poi-5.2.3.jar com/commons-codec-1.15.jar com/commons-math3-3.6.1.jar c om/SparseBitSet-1.2.jar"
After I made that pom.xml change, I tried "mvn package" again and executed "java -jar Macroffects-0.2.0-SNAPSHOT.jar", which brought me to this error in the terminal:
Error: Unable to initialize main class com.solace.SolaceControlCenter Caused by: java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/dump/InvalidFormatException
I then added this plugin to my pom.xml based off of similar issues I was reading on other Stack Overflow posts:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
com.solace.SolaceControlCenter
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
It had no effect on the error message. I read that the error might be linked to the fact that the .jar file cannot find the dependencies because the dependency .jar files are not contained within the .jar file I created. I initially tried to figure out a way to get Maven to do it for me, but to no avail (that question seems to be sparingly answered on Stack Overflow).
My final attempt was to manually put the .jar files (from the list created in the Class-Path: section of the MANIFEST.MF file) into my VS_Code project under com/ to match the Class-Path I set in the pom.xml plugin. This did not change the error message.
I then turned to the pom.xml file, and ran "mvn dependency:analyze" to check if all of my dependencies were being interpreted properly. The result was:
Unable to process: com.solace.ReferenceCreator
Unable to process: com.solace.ExcelEvaluator
[INFO] No dependency problems found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.913 s
[INFO] Finished at: 2023-05-09T12:54:02-04:00
[INFO] ------------------------------------------------------------------------
No dependency problems were found, but the fact that two of my classes were not able to be processed leads me to believe something is wrong, even though when I search for that error on the web, I come up with nothing. What exactly does unable to process mean, and how can I figure out what is causing it?