Recreation
Another stressful week of starting a new project. After creating the Maven build of the JavaFX project, many things went wrong. My task was creating an executable, or at the very least a JAR file, so that the user could just double-click on a desktop application and not have to use an IDE in order to run the application. I went through Intellij and created an artifact to create an output file, a manifest file, and a JAR file so that the JAR, and later on an executable, could be created. That is when things started to go awry.
The first issue that I encountered was that the main class that was defined in the manifest could not be identified. The manifest file defines what file contains the “public static void main” function, the big guy that is basically the start button for the entire program. At first I believed that it was either a classpath issue or an issue with the SDK being used. I tried making sure that the manifest file and the folder that it was in was the correct location. I tried seeing if it had to be in the source folder or resource folder or the same folder that the main class was in. I made sure to check that the SDK I was using was the latest JDK that I had and that the Java home path in my environment variables pointed to the SDK as well. I also made sure that the path to JavaFX was correct in my environment variables as well. I had to define the library of JavaFX in my files into Intellij to make sure that it was recognized, which included a lot of reloading the IDE and trying to rebuild the artifact that I created. I even made sure that the main class was defined in the pom.xml file (basically the settings file) for my artifact. Eventually the main class was recognized.
After all of these attempted fixes, the JAR file created for the artifact was still unable to run in the console. Things started to get even worse as for some reason, the SDK was not recognized by the program. All of the imports and classes had the red underline meaning that the IDE was not loading the SDK properly. Even after re-inputting the SDK, it said that the SDK I was using did not support JavaFX and that I had to define my JavaFX SDK somewhere, which I did for the included libraries and made sure the environment variable for it was in both the user and system variables. It eventually “worked” (there were no red underlines but the imports and classes had no documentation and were not properly colored), but I ran into a new error where FXMLLoader was returning null when trying to get the XML file for the program, trying to connect the XML file to the main file. Here is where I got ultimately stuck and could not find a viable solution.
I eventually recreated the entire project. The first project was created in VS Code which included some files that were not needed and did not set the resource folder as a resource folder in the project structure. This time, I created a new JavaFX project in Intellij and everything started working smoothly. I tried going through the same process of building an artifact to create an output directory, manifest file, and JAR file. I eventually got it past the “no main class found in manifest” error from before but ran into a new error where not everything from JavaFX was being included into the JAR file. From the internet, I tried creating a batch file that included modules that were supposed to help it run the JAR file but I got the same error. That was the summary of how my week went. A lot of failures and restarts. But things are looking a little better. I hope to soon figure out why some of these issues are not working so that I can create something that the user can use.