Wednesday, April 8, 2009

Java Sonic - ListenUp Secutiry Exception.

Hi Friends.
I Have Used ListenUp Applet for A Voice Recording Web Application..In Some browsers it records voice Without any Exception.But In Older versions due some strange reeason This Applte Throws A Secutrity Exception ..I Dont'Know Why??
The Exception Is:

ListenUp version V1.90 (build 406, Mon Nov 17 00:00:00 IST 2008)Caught: java.lang.SecurityException: access denied (javax.sound.sampled.AudioPermission record)

this applet says this because you did not grant permission when the certificate appeared. In fat no certificate was Appeared.. So What is The solutions of this Issue.. After Some Googling i Found god one..
Solution:
(1)Find out Wherethis java applte Installed on your machine.
in my case system drive is C:\ so applet path is:C:\Program Files\Java\j2re1.4.1_01

(2)Find Java.Policy File (C:\Program Files\Java\j2re1.4.1_01\lib\security\java.policy).

(3)Add Code Below at the End of java Policy file..

grant { permission javax.sound.sampled.AudioPermission "record"; };
(4)Restart Your Browser

.. After Installing this code Java.policy will looks like..

// Standard extensions get all permissions by default grant codeBase "file:${java.home}/lib/ext/*" { permission java.security.AllPermission; }; // default permissions granted to all domains grant { // Allows any thread to stop itself using the java.lang.Thread.stop() // method that takes no argument. // Note that this permission is granted by default only to remain // backwards compatible. // It is strongly recommended that you either remove this permission // from this policy file or further restrict it to code sources // that you specify, because Thread.stop() is potentially unsafe. // See "http://java.sun.com/notes" for more information. permission java.lang.RuntimePermission "stopThread"; // allows anyone to listen on un-privileged ports permission java.net.SocketPermission "localhost:1024-", "listen"; // "standard" properies that can be read by anyone permission java.util.PropertyPermission "java.version", "read"; permission java.util.PropertyPermission "java.vendor", "read"; permission java.util.PropertyPermission "java.vendor.url", "read"; permission java.util.PropertyPermission "java.class.version", "read"; permission java.util.PropertyPermission "os.name", "read"; permission java.util.PropertyPermission "os.version", "read"; permission java.util.PropertyPermission "os.arch", "read"; permission java.util.PropertyPermission "file.separator", "read"; permission java.util.PropertyPermission "path.separator", "read"; permission java.util.PropertyPermission "line.separator", "read"; permission java.util.PropertyPermission "java.specification.version", "read"; permission java.util.PropertyPermission "java.specification.vendor", "read"; permission java.util.PropertyPermission "java.specification.name", "read"; permission java.util.PropertyPermission "java.vm.specification.version", "read"; permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; permission java.util.PropertyPermission "java.vm.specification.name", "read"; permission java.util.PropertyPermission "java.vm.version", "read"; permission java.util.PropertyPermission "java.vm.vendor", "read"; permission java.util.PropertyPermission "java.vm.name", "read"; }; grant { permission javax.sound.sampled.AudioPermission "record"; };

Now you will be able to record voice Successfully..
Hope This will useful to you.
Thanks.