JMU CS349 - Developing Multimedia
Gallery Help Policies Solutions Study-Aids Syllabus Tools
Programming Assignment 4


1 Purpose

The primary purpose of this assignment is to help you review (and demonstrate that you have acquired) the knowledge and skills required to: create a program with a simple graphical user interface (GUI), use the application architecture that you will be using for the remainder of the semester, deploy an application as an executable .jar file, and include/use resources in an executable .jar file.

2 Background

As you know, EnhancedRealty is a (fictitious) company that is developing and commercializing applications for the real estate industry. For this assignment, you must implement an application that can be used to display property listings.

3 Documents

EnhancedRealty uses a heavyweight process (as opposed to an agile process) so they have created a fairly detailed set of specifications. They are described in the following document:

4 Resources

You should download the following file into your course downloads directory/folder and then copy it into the resources package.

5 Submission

There is a two part submission process for this assignment.
  1. You must submit (using Gradescope) a .zip file containing all of the code necessary to build your application. Gradescope will only be checking to ensure that your code complies with the course style guide. Hence, you may only submit to Gradescope five times. If you can't get your code to comply with the course style guide within five submissions, you will receive a grade of 0 on the assignment.
  2. You must submit (using Canvas) an executable .jar file named TextApplication.jar (that must NOT contain any of the classes in multimedia2.jar ). Your code must be compiled to run under Java 17 (not higher).

6 Grading

You will receive one of four grades on this assignment -- 100, 75, 50, or 0. You will receive a grade of 100 if your code is essentially correct (i.e., a limited number of system tests do not cause any failures). You will receive a grade of 75 if you appear to have devoted significant effort to the assignment but your code has small defects. You will receive a grade of 50 if you devoted a reasonable amount of effort to the assignment but your code has major defects. You will receive a grade of 0 otherwise and/or if the code you submit to Gradescope code contains any style defects.

Gradescope will assign a maximum grade of 25 (based solely on style). Points will then be awarded manually based on the criteria discussed in the previous paragraph.

7 Help

You might find the following tips/hints helpful.

7.1 The JApplication Lifecycle

Remember, we created the JApplication class so that we can easily create multimedia applications with an appropriate lifecycle. Specifically, in a class that extends JApplication, the init() method will be called when initialization operations should be performed, the start() method will be called when the application might want to start (or re-start) some operations (e.g., when the window is de-iconofied), and the stop() method will be called whenever the application might want to stop itself (e.g., when the window is iconified).

Your code should never call these methods. For example, calling the init() method yourself will cause a problem if you try and working with the main window (or its content pane).

7.2 Displaying the About Dialog

The text in the About Dialog must be read from the file named about.txt. You should put this file in the resources package, along with the Marker class (so that it can be found using a ResourceFinder)

You should display the String using the static showMessageDialog() method in the JOptionPane class.

7.3 Compiling

From the command line, you can compile to a particular version of Java using the -source 17 and -target 17 options. In Eclipse, you can accomplish the same thing by setting the compiler compliance level. See the Departmental Wiki for help (or search the WWW for the terms "Eclipse" "java" "compiler" "compliance").

7.4 Handling Exceptions

You have probably developed the very bad habit of printing stack traces to standard output (i.e., System.out) in catch blocks. That's a particularly problematic practice for GUI applications because they do not have a console.

Instead, you should invoke the showMessageDialog() method in the JOptionPane class, passing it the error messages you want it to display.

7.5 Multimedia Library

The library code you need is available from the course "Help" page. Make sure you understand the difference between using the source code and using the .jar file and why you might want to do both at different times.

For help adding the .jar file containing the .class files to an Eclipse project, see the Departmental Wiki.

7.6 The Manifest

You must include a manifest file (named TextApplication.mf) in TextApplication.jar that contains something like the following:
Manifest-Version: 1.2
Main-Class: homebase.TextApplication
Class-Path: multimedia2.jar
    
(Note: Manifests must end with a newline character.)

7.7 Creating the Executable .jar File

You can create the TextApplication.jar file either from an IDE or from a terminal/shell.

From the command line, you should use a command something like the following (from the directory above the .class files):

jar -cvfm TextApplication.jar TextApplication.mf gui government homebase realestate resources
    

Obviously, you should understand all of the arguments before you behave like a lemming.

From Eclipse, you should use a process like the one described on the CS Department's wiki.

7.8 Testing the Executable .jar File

When you test the application, make sure you do so in a "clean" directory. That is, copy TextApplication.jar and multimedia2.jar to a directory that contains nothing else (to make sure that those are the only files being used). You could otherwise be using .class files or the .txt file from the local file system and not know it.

You should then be able to click/double-click (depending on your OS) the executable .jar file to run the application. (Of course, you may first have to associate .jar files with the appropriate executable, in this case, java and/or make the file executable.)

From the command line, you can execute the application using either java -jar TextApplication.jar or java -cp TextApplication.jar homebase.TextApplication (because the manifest instructs the interpreter to use multimedia2.jar).

Depending on how you read in the data files, you may need to include the complete path to the file.

Copyright 2024