Lab: Skills - Creating Executable .jar Files in Eclipse
         
            
         
         
            Instructions:
  Answer the following questions one at a time. After answering each question,
  check your answer (by clicking on the check-mark icon if it is available)
  before proceeding to the next question.
  
            
            
                
         
         
            Getting Ready:
   Before going any further, you should:
   
               - 
    This lab is a simulation of a part of the process that is being used
    to create a product named Taxeze
    for the (hypothetical) company
    FreeMarket. 
    The team is using an incremental process known as Scrum, which divides the
    work up into sprints.
    
    If you have not already done so, you must complete
    the lab on serialization
    before you can start this lab. If you also completed
    the lab on GUI
    modification you can start from there.
    
                
               - 
    Read the course "Help" page on that discusses
    
      creating executable/runnable 
    
.jar files in Eclipse.
     
               - 
    Read the sprintable stories.
    
 
            
         
         
            1. Creating an Executable .jar File with Defects: 
  This part of the lab will help you understand why the existing
  implementation is not ready to be deployed.
  
               - 
    Without changing the code, create an executable 
.jar
    file for Taxeze.
     
               - 
    Run Taxeze (from outside of the IDE) using the
    executable 
.jar file. What are the defects?
    
    
                  
                     
                        
                           
                              
    The buttons do not have icons. (In fact, because of this problem,
    the buttons may not exist or be too small to see.)
    
                              
                           
                        
                      
                  
                  
                
               - 
    Inspect the code that loads the icons. Where are they loaded from?
    
    
                  
                     
                        
                           
                              
    The working directory/folder (since no path is specified). When
    Eclipse runs an application, it first changes the working
    directory to the project directory/folder. Since there is where
    the icons are, the application runs properly from inside of
    Eclipse.
    
                              
                           
                        
                      
                  
                  
                
               - 
    What needs to be done instead?
    
    
                  
                     
                        
                           
                              
    We need to load the icons from inside of the .jar file.
    One way to do this is to use   
    the ClassLoader infrastructure.
    
                              
                           
                        
                      
                  
                  
                
            
          
         
            2. Tasks Required to Satisfy the Acceptance Criteria: 
  The sprintable stories have been decomposed into the following tasks.
  
               - 
    Create an 
icons package inside the src
    directory/folder.
     
               - 
    If necessary, right-click on the folder, pull down to "Build Path", and
    across to "Include" to ensure that it will be copied to the 
    
bin directory when the code is executed. (If "Include" isn't
    an option then it has already been included.)
     
               - 
    Copy the icons into the 
icons package in the IDE.
     
               - 
    Delete the original icons.
    
 
               - 
    Modify the 
loadImageIcon() method in the 
    TaxezeWindow class so that it uses the ClassLoader
    infrastructure.
    
    
                  
                     
                        
                           
                              
                                 
                                    
  private ImageIcon loadImageIcon(String name)
  {
    URL url = this.getClass().getResource("/icons/"+name);
    ImageIcon icon = new ImageIcon(url);
    return icon;
  }
    
                                 
                               
                              
                           
                        
                      
                  
                  
                
               - 
    Run the application from within Eclipse to make sure it still has
    the icons.
    
 
               - 
    Create an executable 
.jar file.
     
               - 
    Run the executable 
.jar file to make sure it now has the icons.
     
               - 
    Change the icon of the executable 
.jar file.