Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call embedded java function in a web page

Here is the function that i want to use in a web page and want to call it in script node as other javascript functions. But could you please guide me on how to achieve it.

public static String getClipboard() {

    Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);

    try {
        if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            String text = (String)t.getTransferData(DataFlavor.stringFlavor);
            return text;
        }
    } catch (UnsupportedFlavorException e) {
    } catch (IOException e) {
    }
    return null;
}

I am completely new to this concept.. If you can answer this question, that will be very helpful.. Thanks

like image 885
Exception Avatar asked May 19 '26 09:05

Exception


2 Answers

Use LiveConnect to enable bidirectional communication between Java and JavaScript within a page.

like image 147
Andrew Gilmartin Avatar answered May 20 '26 22:05

Andrew Gilmartin


You can only call interact with Java if it's running on a Java Applet.

If you need to interact with the clipboard in Javascript, this Stack Overflow question answers that for you.

like image 29
lsoliveira Avatar answered May 20 '26 21:05

lsoliveira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!