1 Reply Latest reply on Sep 13, 2009 7:15 AM by BKBK

    Coldfusion Jrun accessing server Clipboard

    Amosl Level 1

      Ok.  I have a java class that outputs the system clipboard.  so if you copy text on your server with a ctrl c, it saves it to the clipboard.  when I run the class via command line it is getting this text, however, when coldfusion calls this same class it sees the clipboard as being null. any idea what I can do to debug this?

      I know his is vague, so if you have any questions shoot away.

       

      my java class is as follows:

       

       

      import java.awt.AWTException;
      import java.awt.Robot;
      import java.awt.Rectangle;
      import java.awt.Toolkit;
      import java.awt.image.BufferedImage;
      import java.io.*;
      import javax.imageio.ImageIO;
      import java.awt.datatransfer.Clipboard;
      import java.awt.event.KeyEvent;
      import java.awt.datatransfer.*;
      import java.io.IOException;
      import java.awt.Image;
      import javax.imageio.*;

       


      public class ScreenCapture2 {

       


      public static void main(String[] args)  {
      runit();
      }

       

       

       

      public static void runit()  {
      Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
      System.out.println(getClipboardData());
      }    

       

       

       

      public static String getClipboardData() {
              String clipboardText;
              Transferable trans = Toolkit.getDefaultToolkit().getSystemClipboard()
                      .getContents(null);

       

              try {
                  if (trans != null
                          && trans.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                      clipboardText = (String) trans
                              .getTransferData(DataFlavor.stringFlavor);
                      return clipboardText;
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
              return null;
          }

       

       

       

      coldfusion meanwhile calls a batch file that executes this class.