Gaining clipboard access in Applet for Ubuntu Firefox

I am running 64-bit Ubuntu with an applet in Firefox. When the applet tries to read the clipboard. I get this error:

Error: uncaught exception: LiveConnectPermissionNeeded access denied (java.awt.AWTPermission accessClipboard)

I would like to enable buffer access for this particular applet. Any idea how? I am running the IcedTea plugin. This works fine with IE on Windows (using the JDK6 plugin).

I tried installing the Oracle Java 6 plugin: sudo apt-get install sun-java6-plugin

It did not seem to have usable files, and it did not give any errors or warnings during installation.

I am open to any ideas on how to make this work.

+4
source share
4 answers

I'm glad you asked. See the Copy section in the sandboxed application. at 1.6.0_24 + in OTN for a potential solution.

In fact, I would appreciate your test results for this code that I posted - details in the subject. I have moved from the Swing forum to the Java Programming forum to try to get some results for any OS other than Windows, but have not yet received any results other than Windows.

If you insert data and comments here, I will include it in the Results Table and go back.

0
source

Not sure if you need to run this in the sandbox or if this is a problem signing your applet. But the permission error is most likely due to the fact that your access to the clipboards is not completed in the privileged block. Here is an example of its wrapping. You must also sign the applet.

  Clipboard systemClipboard = (Clipboard) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Clipboard tempClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); return tempClipboard; } }); // get the contents on the clipboard in a // Transferable object Transferable clipboardContents = systemClipboard.getContents(null); 
0
source

As you did not answer the questions, here is another tip:

To change the Sun plugin after installation, you need to do sudo update-java-alternatives java-6-sun and then restart Firefox (or at least close and reopen any tabs containing Java applets).

Note. This changes not only the plugin, but also the default JVM for the entire system. If you want to change the plugin, add the --plugin switch (before java-6-sun ).

But let us know if the Sun plugin is using any changes.

0
source

You can find useful information in this thread.

https://askubuntu.com/questions/42122/cant-copy-from-clipboard-to-any-java-applet

It looks like the java.awt library does not have access to the system buffer by default.

Edit: The above solution was ultimately useless in my case. I was able to access the elements in the system clipboard, which I placed in java applications, following the recommendations to download the Glipper mentioned in the stream below.

Java - copied clipboard contents disappear after program exit

0
source

Source: https://habr.com/ru/post/1346248/


All Articles