Results 1 to 3 of 3
  1. #1
    JR2010 is offline Member
    Join Date
    Apr 2011
    Posts
    15
    Rep Power
    0

    Default Have no Idea why this class is not working

    I have to create a file for a program for school, and this is the last thing I have to do for my final program to work, but it is not working for some reason can someone spot the error. The lines that are getting errors are 11,12, and 16.


    Java Code:
    import java.util.*;
    import javax.swing.JOptionPane;
    /**
     *
     * @author Julie
     */
    public class SaveF {
       
        final Formatter s;
        
        try{
        s = new Formatter("C:\\data\\inventory.dat");
        
         JOptionPane.showMessageDialog(null, "You have created a file","File Created", JOptionPane.PLAIN_MESSAGE);
        }//end of try
        catch (Exception e){
          JOptionPane.showMessageDialog(null, "Error in save file!","ERROR",JOptionPane.ERROR_MESSAGE);
        }//end catch
        
    }//end SaveF

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Hello, Julie, thank you for using code tags and supplying which lines generate the errors, however; before I get into the details of the code, would you mind posting the exact errors?(post them in code tags please)

    Would you also mind providing the end goal of this snippet? Why are you using formatter exactly? It seems like it has something to do with a file.
    Last edited by sunde887; 05-02-2011 at 06:41 AM.

  3. #3
    JR2010 is offline Member
    Join Date
    Apr 2011
    Posts
    15
    Rep Power
    0

    Default

    I figured it out, but thanks for the help. I forgot to add public static void and it worked like a charm.

Similar Threads

  1. Replies: 15
    Last Post: 04-24-2011, 12:49 PM
  2. New to java - class not working
    By rrjava in forum New To Java
    Replies: 3
    Last Post: 03-10-2011, 04:46 AM
  3. java.system.class.loader Not Working
    By kg1 in forum Advanced Java
    Replies: 2
    Last Post: 12-06-2010, 10:41 PM
  4. Replies: 2
    Last Post: 03-01-2010, 04:19 PM
  5. TextIO class not working
    By trudy in forum New To Java
    Replies: 4
    Last Post: 12-30-2009, 08:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •