Tuesday Jul 19, 2011

Copy And Paste in Java Applets

For a while now, I've noticed that copy and paste no longer works in the Admin Applets in UCM.  This was a minor annoyance as I was typically just trying to copy and paste a content ID or line of scripting.  But it suddenly became a real problem for me when I needed to create an option list of countries.  I had the list nicely formatted in my Notepad++, but no way to copy and paste it into my option list dialog.

Well, it turns out with the release of the Java Plug-in 1.6.0_24 in February 2011, copy and paste from the system clipboard was deemed a security hole and disabled.  You can copy and paste BETWEEN applets.  But if you try to use something from your main clipboard, it can't be copied in.  

So there are a couple of options for a workaround.  You can roll back to an earlier version of the plug-in.  That will work, but chances are all future releases will still keep copy and paste disabled, so you'd never be able to upgrade.  

The other alternative is to provide a custom java security policy file which enables access to the system clipboard again.  

  1. First locate your local Java Security Policy file.  The file is named java.policy and should be in the lib\security folder of your Java installation.  On Windows 7, it can be found at C:\Program Files (x86)\Java\jre6\lib\security.
  2. Copy this file to your home folder (ex. C:\Users\Kyle).
  3. Rename the file to .java.policy (note the period at the beginning). 
  4. Edit the file in a text editor.  Locate the line of text
    // "standard" properies that can be read by anyone

  5. Add the following line just below this line.
    // "standard" properies that can be read by anyone
    permission java.awt.AWTPermission "accessClipboard";

  6. Save the file.
  7. Close any open browsers and ensure that Java is not running before testing.

 

 While you can modify the java.policy file directly in the lib/security folder, chances are it will get overwritten again on the next JRE update.  This method should allow those changes to persist.

About

Kyle Hatlestad is a Solution Architect in the WebCenter Architecture group (A-Team) who works with WebCenter Content and other products in the WebCenter & Fusion Middleware portfolios. The WebCenter A-Team blog can be found at: https://blogs.oracle.com/ ateam_webcenter/

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today