Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JFrame java.io.FilePermission

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JFrame java.io.FilePermission

    I have a program that only uses JFrame, not JApplet. This is the first time I have had it throw a security exception with FileInputStream and FileOutputStream. Here is the piece of code that is throwing the exception:
     
    public static Vector<MyEvent> grabEventVector()
        {
            Vector<MyEvent> v = new Vector();
     
    	try{
                FileInputStream f = new FileInputStream("Data.txt");
                ObjectInputStream s = new ObjectInputStream(f);
     
                v=(Vector<MyEvent>) s.readObject();
                s.close();
     
    	}catch(Exception e)
    	{
                error.setText(e.getMessage());
     
    	}
     
            return v;
       }

    I understand that this is probably not enough of my code to really help. So here is some context:

    package todoitbetterapp;
     
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.util.Vector;
    import javax.swing.JLabel;
     
     
     
    public class GlobalClasses 
    {
     
        public static JLabel error;
     
        public void GlobalClasses()
        {
            error = new JLabel(" ");
     
        }
     
        //Global Methods
        public static void writeEventVector(Vector<MyEvent> v)//Writes Vector<MyEvent> to file
        {
    		try{
    			 FileOutputStream f = new FileOutputStream ("Data.txt");
     			 ObjectOutputStream s = new ObjectOutputStream(f);
     
    			 s.writeObject(v);
    			 s.flush();
    			 s.close();
     
    		}catch(Exception ex)
    		{
    			//error.setText(ex.getMessage());
    		}
        }
     
     
     
     
        public static Vector<MyEvent> grabEventVector()
        {
            Vector<MyEvent> v = new Vector();
     
    	try{
                FileInputStream f = new FileInputStream("Data.txt");
                ObjectInputStream s = new ObjectInputStream(f);
     
                v=(Vector<MyEvent>) s.readObject();
                s.close();
     
    	}catch(Exception e)
    	{
                error.setText(e.getMessage());
     
    	}
     
            return v;
        }
     
     
     
    }

    These methods get called often by several other classes, so I put them all into one convenient class. Please let me know if I need to put more code down.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JFrame java.io.FilePermission

    Please post the full text of the error message.
    Change the code by adding a call to printStackTrace in the catch block so you get the FULL error message

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JFrame java.io.FilePermission

    I figured it out. It was a silly mistake. I working in NetBeans IDE and my configuration was in WebStart... When I changed it to <default config> I no longer got the errors. Since it is more a personal app, I really don't care. Thanks though.

Similar Threads

  1. Shortcut key to java JFrame
    By jakethesnake2x in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 28th, 2011, 07:32 PM
  2. connecting jframe to another jframe
    By ajtambalo in forum Member Introductions
    Replies: 2
    Last Post: May 11th, 2011, 11:24 AM
  3. [SOLVED] Java Noob, Jframe in Applet.
    By rLLZORS in forum AWT / Java Swing
    Replies: 2
    Last Post: May 5th, 2011, 10:42 AM
  4. Creating subsequent frames in java with Jframe
    By bondage in forum AWT / Java Swing
    Replies: 3
    Last Post: April 11th, 2011, 07:28 AM
  5. Java Gif image problem in JFrame
    By Zachary Wins in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 23rd, 2010, 08:51 PM

Tags for this Thread