List icon Contents

Configuring IntelliJ IDEA

This tutorial shows how to create a Java project in IntelliJ IDEA, configure it to use JxBrowser, create and run a simple Hello World application.

Creating a new project

Run IntelliJ IDEA and create a new Java Project:

Creating new project in IntelliJ

Enter your project name and click the Create button.

Adding JxBrowser JARs

Add JxBrowser JARs to the Java Module dependencies:

Adding Module Deps

First, add modules with Java classes:

Viewing Module Deps

Then, add modules with binary files. When adding them, IntelliJ may ask you to recognize what kind of files you’re adding. In this case, choose the Classes option when IDE prompts you:

File category in JAR

Viewing All Module Deps

Creating a program

Create the HelloWorld class:

New Class New Class Name

Insert the following source code of the HelloWorld example:

import static com.teamdev.jxbrowser.engine.RenderingMode.HARDWARE_ACCELERATED;

import com.teamdev.jxbrowser.browser.Browser;
import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.view.swing.BrowserView;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

public class HelloWorld {

    public static void main(String[] args) {
        // Creating and running Chromium engine.
        Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
        Browser browser = engine.newBrowser();

        SwingUtilities.invokeLater(() -> {
            // Creating Swing component for rendering web content
            // loaded in the given Browser instance.
            BrowserView view = BrowserView.newInstance(browser);

            // Creating and displaying Swing app frame.
            JFrame frame = new JFrame("Hello World");
            // Close Engine and close the app window.
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
            JTextField addressBar = new JTextField("");
            addressBar.addActionListener(e ->
            frame.add(addressBar, BorderLayout.NORTH);
            frame.add(view, BorderLayout.CENTER);
            frame.setSize(800, 500);


Running the program

Run the HelloWorld program:

Run Program HelloWorld Program

Go Top