Results 1 to 6 of 6
  1. #1
    lucas_santos is offline Member
    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Default SecurityException in Java Applet

    Hi,

    I made a Applet but when I put an <APPLET> tag in my HTML, occurs an exception

    SecurityException : Could not open file policy C:\Program Files\Java\jdk1.7.0_05\bin\raystore: sun.security.provider.PolicyParser$ParsingExceptio n line 1: expected [;] found[pípí]

    I tryied to follow this sample, but I don't know what to do in step 7.

    Can anyone help me ?

  2. #2
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: SecurityException in Java Applet

    You're using very old sample. This book is from 1999, and some examples from this sample are from 1998.

    You should use newer samples and examples for learning. Lots of things have changed since 1999.

    Instead of using "import java.applet.Applet;" now in usage is "import javax.swing.JApplet;"

    Newer version for old sample code for class SignedAppletDemo.java (from your sample) would be something like that:

    Java Code:
    import java.awt.Color;
    import java.awt.Graphics;
    import java.io.FileWriter;
    import java.io.IOException;
    
    import javax.swing.JApplet;
    
    
    public class SignedAppletDemo extends JApplet {
    	public String test() {
    		setBackground(Color.white);
    		
    		String fileName = System.getProperty("user.home") + 
    				System.getProperty("file.separator") +
    				"demo.ini";
    		String msg = "This message was written by a signed applet!\n";
    		String s;
    		
    		try {
    			FileWriter fos = new FileWriter(fileName);
    			fos.write(msg, 0, msg.length());
    			fos.close();
    			s = new String("Successfully created file :" + fileName);
    		} catch(IOException e) {
    			System.out.println("Exception e = " + e);
    			e.printStackTrace();
    			s = new String("Unable to create file: " + fileName);
    		}
    		return s;
    	}
    	
    	public void paint(Graphics g) {
    		g.setColor(Color.blue);
    		g.drawString("Signed Applet Demo", 120, 50);
    		g.setColor(Color.magenta);
    		g.drawString(test(), 50, 100);
    	}
    }

  3. #3
    lucas_santos is offline Member
    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Default Re: SecurityException in Java Applet

    Thanks. But when I put the Applet in my Web Application, occurs the ExceptionInInitializerError. My applet extends from JApplet.

  4. #4
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: SecurityException in Java Applet

    ^Please give us full error message.

  5. #5
    lucas_santos is offline Member
    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Default Re: SecurityException in Java Applet

    How can I do that? The warning message just show me the name of the exception, nothing more. Without html, works fine.

  6. #6
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: SecurityException in Java Applet

    ^This is one example of ExceptionInInitializerError message. This error message has maybe 30-40 lines:

    java.lang.ExceptionInInitializerError
    at org.openscience.cdk.libio.cml.Convertor.cdkAtomCon tainerToCMLMolecule ( Convertor.java:184 )
    at org.openscience.cdk.libio.cml.Convertor.cdkMolecul eToCMLMolecule ( Convertor.java :180 )
    at org.openscience.cdk.io.CMLWriter.write ( CMLWriter.java:173 ) ... 10 more
    and
    Caused by: java.security.AccessControlException: access denied ( java.util.logging.LoggingPermission control )
    at java.security.AccessControlContext.checkPermission ( Unknown Source )
    at java.security.AccessController.checkPermission ( Unknown Source )
    at java.lang.SecurityManager.checkPermission ( Unknown Source )
    at java.util.logging.LogManager.checkAccess ( Unknown Source )
    at java.util.logging.Logger.setLevel ( Unknown Source )
    at org.xmlcml.cml.element.CMLMolecule. < clinit > ( Unknown Source )
    ... 19 more

Similar Threads

  1. Replies: 2
    Last Post: 02-12-2012, 01:32 AM
  2. Replies: 2
    Last Post: 09-07-2011, 08:03 PM
  3. Replies: 30
    Last Post: 08-26-2011, 10:05 PM
  4. Caused by: java.lang.SecurityException: Access denied
    By Dattatray in forum Advanced Java
    Replies: 0
    Last Post: 12-17-2010, 11:46 AM
  5. Replies: 1
    Last Post: 11-17-2010, 06:48 AM

Tags for this Thread

Posting Permissions

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