C211 Problem Solving and Programming II

C211 Creating a Jar File

When you turn in your team projects, you need to include a jar file so that I can also test it. Here are some instructions to do that in the different IDEs.

Eclipse

For Eclipse follow these steps:

NetBeans

In NetBeans, here is how I made it work. I used the CelsiusConverter project for this. Once your project compiles and runs, go to the Project Files folder and click on the file pom.xml. You will see in this file something like

<project>

...

</project>

Add a new line just before the closing project tag, and paste the following into it:

<build>
 <plugins>
     <plugin> 

                <!-- Building an executable jar -->

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                  <archive>
                    <manifest>

                    <!-- give full qualified name of your main class-->
                      <mainClass>CelsiusConverterGUI</mainClass>

                    </manifest>
                  </archive>
                </configuration>
    </plugin>
 </plugins>
</build>

Then change the name of the class CelsiusConverterGUI into the name of the main class in your project. The problem is that NetBeans can easily create a jar file. but it doesn't include the information about the main class properly, and I couldn't find in the properties where to add it.

While you're there, you can also edit the name or version of the jar file it creates. By default, it adds 1.0-SNAPSHOT to the name of the jar file, which I found annoying, so I changed it to 1.0.

After you save this file, go to the Run menu and do Build Project. Then in the project folder, in the target folder, you will find the jar file. You should be able to run it by double-clicking on it.

Project Submission

Please upload the jar file in the GitHub repository of the project.