Search code examples
jxbrowser

console.log stmts. not outputted in java program


I have the following which basically is c&p from the JxBrowser documentation:

public class HelloWorld {

    public static void main(String[] args) {
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame("JxBrowser - Hello World");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(500, 400);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        browser.addConsoleListener((ConsoleEvent event) -> {
            System.out.println("Level: " + event.getLevel());
            System.out.println("Message: " + event.getMessage());
        });
        browser.loadURL("http://localhost:3000/test.html");

    }
}

The localhost server is a simple html file that contains a script calling console.log("hello world"). I would expect to see the "hello world" in my java console as well as I have setup a ConsoleListener. But nothing is outputted. I'm using version 6.9 of JxBrowser and are working on a Ubuntu 16.04 machine. Anybody got a hint?


Solution

  • I've tried your example on 6.16 and it seems that that issue was resolved in that version. Please, try version 6.16 of JxBrowser. You can find JxBrowser 6.16 by this link.