New version is available You are viewing the documentation for JxBrowser 6 which is not supported since December 2019. Go to the current documentation.
List icon 目录

In this guide you will learn how to download JxBrowser library, get evaluation license, create and run your first Java Swing application that loads and displays HTML content from string.

Prerequisites

Please make sure your system meets the software and hardware requirements.

The instruction about how to perform the following actions in your favorite IDE you can find at IntelliJ IDEA, Eclipse or NetBeans.

Download Library

Navigate to https://teamdev.com/jxbrowser and click Download. Unzip the downloaded archive into some directory (e.g. D:\Projects\MyProject\). When you unzip the archive it will give you directory structure inside D:\Projects\MyProject\ as follows:

lib\
    jxbrowser.jar          // JxBrowser library
    jxbrowser-win32.jar    // Chromium 32-bit binaries for Windows
    jxbrowser-win64.jar    // Chromium 64-bit binaries for Windows
    jxbrowser-mac.jar      // Chromium 64-bit binaries for Mac OS X
    jxbrowser-linux64.jar  // Chromium 64-bit binaries for Linux 64-bit
samples\                   // API samples
doc\javadoc\               // Public API Javadocs
doc\guide\                 // Programmer's and Quick Start Guide
demo\                      // Demo application
Readme.txt                 // Readme file
License agreement.txt      // License agreement

Get License

JxBrowser 6 reached its end of life in December 2019. There is no way to request an evaluation license for this version anymore. Please use your commercial license instead.

Copy your license.jar file to the D:\Projects\MyProject\lib\ directory.

lib\
    jxbrowser.jar          // JxBrowser library
    jxbrowser-win32.jar    // Chromium 32-bit binaries for Windows
    jxbrowser-win64.jar    // Chromium 64-bit binaries for Windows
    jxbrowser-mac.jar      // Chromium 64-bit binaries for Mac OS X
    jxbrowser-linux64.jar  // Chromium 64-bit binaries for Linux 64-bit
    license.jar            // Your commercial license

Create Java Project

Create a new Java Project using your favorite IDE.

Add Libraries

In your favorite IDE add JxBrowser libraries and evaluation license in the Project:

D:\Projects\MyProject\lib\jxbrowser.jar
D:\Projects\MyProject\lib\jxbrowser-win32.jar
D:\Projects\MyProject\lib\jxbrowser-win64.jar
D:\Projects\MyProject\lib\jxbrowser-mac.jar
D:\Projects\MyProject\lib\jxbrowser-linux64.jar
D:\Projects\MyProject\lib\license.jar

Create HelloWorld Example

In Java Project create a new HelloWorld Java class with the following content.

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

import javax.swing.*;
import java.awt.*;

/**
 * The sample demonstrates how to create Browser instance, embed it,
 * load HTML content from string, and display it.
 */
public final 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.loadHTML("<html><body><h1>Hello World!</h1></body></html>");
    }
}

Run the Program

Compile and run HelloWorld program. You will see the following window:

Hello JxBrowser

Go Top