Site Sponsors:
Java Clipboard Woes on Ununtu 
Here is a classic tao of software testing - run it once, and the test passes. Right?

Well, by way of a VERY hard to find testing oversight, here is a bug under Java on Ubuntu. -The test works great the first time. Run the EXACT same test again and ... Boom! --Life suddenly gets mysterious:
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.io.StringReader;

/**
* CONCLUSION: CLIPBOARD ON UBUNTU RUNS FINE WHEN JAVA PROGRAM IS RUNNING. ERROR
* AFTER PROGRAM EXITS & CONTENT IS PASTED BACK INTO JAVA. Proof: Run this class
* twice - first time should run okay.The second time will fail. To clear the
* error, merely copy something ELSE to the clipboard.
*
* @author profnagy
*/
public class JaveClipboardWoes {
/*
Exception in thread "main" java.awt.datatransfer.UnsupportedFlavorException: Unicode String
at sun.awt.datatransfer.ClipboardTransferable.getTransferData(ClipboardTransferable.java:160)
at daily.newsletter._ClipboardWoes.main(_ClipboardWoes.java:32)
Java Result: 1
*/
public static void main_string() throws Exception {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
DataFlavor[] flavors = cb.getAvailableDataFlavors();
for (DataFlavor flav : flavors) {
System.out.println(flav.getMimeType());
}
// get whatever is on the clipboard
String str = (String) cb.getContents(null).getTransferData(DataFlavor.stringFlavor);
System.out.println(str);
// put a unicode string on the clipboard
StringSelection data = new StringSelection("Testing Is Important");
cb.setContents(data, data);
// get the unicode string okay!
System.out.println(cb.getContents(null).getTransferData(DataFlavor.stringFlavor));
}

/*
Exception in thread "main" java.awt.datatransfer.UnsupportedFlavorException: Plain Text
at sun.awt.datatransfer.ClipboardTransferable.getTransferData(ClipboardTransferable.java:160)
at daily.newsletter._ClipboardWoes.main(_ClipboardWoes.java:48)
Java Result: 1
*/
public static void main_text() throws Exception {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
DataFlavor[] flavors = cb.getAvailableDataFlavors();
for (DataFlavor flav : flavors) {
System.out.println(flav.getMimeType());
}
// get whatever is on the clipboard
StringReader str = (StringReader) cb.getContents(null).getTransferData(DataFlavor.plainTextFlavor);
System.out.println(str);
// put a unicode string on the clipboard
StringSelection data = new StringSelection("Important, testing is!");
cb.setContents(data, data);
// get the unicode string okay!
System.out.println(cb.getContents(null).getTransferData(DataFlavor.plainTextFlavor));
}

public static void main(String[] args) throws Exception {
main_text();
main_string();
main_text();
main_string();
}
}

While we are running Sun's JDK on Ubuntu 10.04, the problem has been reported elsewhere.

Software developers everywhere can probably relate to this happen-stance. While vexing, the fact that the problem has yet to be fixed - after 5 or so years of testing - should tell us allot?

Enjoy the Journey!



[ view entry ] ( 1609 views )   |  permalink
Policy Permission: Copy & Paste in Java 
Sure I love C#, C/C++, Delphi, VB.NET, JavaScript, Ruby, and PHP, but in my spare time I write allot of Java.

Why Java? Because when it comes to sharing, be it via applets or applications, Java simply shares allot father.

Yet across the globe, folks who are used to being able to share their clipboard with the Java have been disturbed by what seems to be yet another arbitrary edict: somewhere, someone felt that the world would be safer if clipboard sharing was disabled.



Ignoring the idea that the ability to exchange data is a user-driven operation, the fact that a program can dump huge amount of data to a clipboard is not a problem anyone I know of has ever encountered. Yet, as new-found knowledge has ways that wisdom knows nothing of, the fact remains - by default - that another traditional convenience can be denied.

Well, another nicety lost.... yet (hopefully) merely temporarily interrupted? (Ever wonder if Microsoft hires folks to sabotage open efforts? -I sure do!)

While remediation of the problem promises to allow everything from FireFox to Opera to use JVM plug-ins once again, until we are far, far, past this unfortunate event, folks will want to know how to fix their local policy file.

The 'related link' below has an excellent post. The succinct information will help billions of people enjoy the features of several applets here, as well in the Open Source Projects across the cyberverse.

Linux and Windows user alike might be surprised to discover that a java.policy files might not exist. Not having a java.policy file is not too unusual. For those who would like an example to help them create a java.policy file at the proper location, here is a content cut & (ahem) paste:

grant { 
permission java.awt.AWTPermission "accessClipboard";
};



Enjoy,

-Rn



[ view entry ] ( 1983 views )   |  permalink  |  related link
New Look for EzLog 
One knows that one needs to make something easier to use when YOU find yourself wishing it were so...



Perhaps that is why we software developers always have the best tools?

After a little thought, it occurred to us that even a time tracking tool might do well to use a "calculator" metaphor. -Once EzLog4J is installed, simply move your cursor over each button to see what each of the above buttons do.

Note that while the new keys do the same as pressing the above key-labelled buttons, that the old keyboard equivalents (INS = new entry, DEL = remove selected entry, etc.) still work as expected.

Hope you find it useful!

[ view entry ] ( 1896 views )   |  permalink  |  related link

<<First <Back | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Next> Last>>