Using the clipboard with JavaHASE applets

Purpose

JavaHASE applets contain full HASE simulation models of computer systems which allow a user's own code and data to be loaded into memory (modelled as ARRAYS). This can be done by editting the existing contents of the various ARRAYS, but it is much more convenient to be able to cut text from an edit window or a Webpage and paste it into the ARRAY editing window.

To communicate data among applications with the copy & paste facility, the system (Linux, Window, ...) uses the clipboard. To prevent malicious applets from spying on information which goes to the clipboard, standard security managers for applets do not allow access to the clipboard. Happily, the security manager can be configured manually, on the computer which launchs the Java Virtual Machine(JVM) (appletviewer or Browser). This page explains how to configure the security manager to be able to use the clipboard.

Principle

Basically, any java user can configure HIS OWN Security Manager with a security policy file (See complete information from Sun). On linux, each user who wants to configure the JVM will launch from his/her account has to create or modify the file ~/.java.policy to modify security manager properties. On Windows, the simplest way is to modify the C:\Program files\JavaSoft\JRE\1.3.1\lib\security\java.policy file. The information in red may depends on the JVM release being used (1.3.1 or other) and on the path in which the JVM has been installed. To check the JVM installation path, go the windows 'Control Panel'(start menu/Settings), click on the icon related to the JVM being used (Java plug-in 1.3.1), go to the 'Advanced' bookmark, click on the 'Use Java plug-in Default' list box and read the path into which your plug-in is installed.

How to modify the java policy file

If the file already exists, add the following lines at the end of the file. Otherwise, just create a file which contains these lines :
grant codeBase "http://www.dcs.ed.ac.uk/home/hase/javahase/*" {
permission java.awt.AWTPermission "accessClipboard";
};
This means, to give a permission to access the Clipboard to any applets the url of which starts with http://www.dcs.ed.ac.uk/home/hase/javahase/

How to copy & paste

Copy any text from standard applications (Netscape, emacs, ...) using the copy menu item from the edit menu. Then paste it into the edit window with either CTRL+V or mouse middle button.

Return to previous page


Frederic Mallet
Last modified: Tue Feb 12 13:51:18 GMT 2002