Search code examples
javajava-web-startjmf

JMF- no permission to write files from applet


I am creating a application using jmf that will be launched on a user's computer with java web start and a jnlp file. I would like to create a jpg image of a JFrame and then use those images to make a quicktime movie. All of this works when I run as a stand alone application at is just on the user's computer. The problem is that when it is launched through web start I get an error saying that I do not have permissions to write files from applets. I understand that this is something that is set with the jmf registry tool, but I don't want my users to have to install jmf on their machines. I saw that there was one solution from the java bugs site. It was to add:

com.sun.media.util.Registry.set("secure.allowSaveFileFromApplets", true)

System.setSecurityManager()

The second line of that actually creates an error, so I took it out. Nothing happened when I ran the code with the first line in the constructor of the class that uses jmf. I was wondering if anybody had any solutions to this (ways to allow jmf to write files from an applet without installing jmf) or suggestions to make the solution from the java bug site actually work. Thanks.

Edit- The applet and the jars are all signed

Edit- When I said there was an error from the second line of code I meant something like a syntax error from eclipse saying that the parenthesis cannot be empty. I had not thought to use the code with null. I have tried it now though, and adding the line does not make a difference.
I'm not entirely clear about why my program is considered an applet, but the error the code throws specifically says: "java.lang.RuntimeException: No permissions to write files from applets." So I figure I may as well call my program what java its calling it.


Solution

  • I'm pretty sure I've figured out how to make this work.

    First you need to make sure that you install the cross platform version of jmf. You will then need to use the command line to run the JMFRegistry with the following command in the JMF-2.1.1e\lib folder.

    java -cp jmf.jar;mediaplayer.jar;multiplayer.jar JMFRegistry

    Now you need to check the boxes to allow for writing and capturing. You will now need to open the JMFCustomizer to create your own jar. You will run the following command in the same folder as last time.

    java -cp customizer.jar; jmf.jar;mediaplayer.jar;multiplayer.jar JMFCustomizer

    You will then need to follow the steps to create a custom jar file, making sure to use the jmf.jar file that came with this install.

    Personally I just included everything that had to do with recording videos, but you can mess around with the customizer as much as you need to make a jar that works for you.

    Also as an added precaution I added in the code I mentioned in my question as well as the line:

    JMFSecurityManager.enableSecurityFeatures();

    These were put in the constructor of the class that calls jmf.

    Hopefully this will help someone else having A similar problem.