• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion Jrun accessing server Clipboard

New Here ,
Sep 12, 2009 Sep 12, 2009

Copy link to clipboard

Copied

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.

TOPICS
Advanced techniques

Views

683

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2009 Sep 13, 2009

Copy link to clipboard

Copied

LATEST

What happens when you send the output to file, like this

<cfexecute name="java" arguments="-classpath c:\javaProjects\test\ScreenCapture2" outputFile="C:\javaProjects\test\clipboard.txt" />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation