In this Quick Start 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.


Requirements: JDK 1.6 and higher


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


1. Download Library

To download JxBrowser library navigate to http://www.teamdev.com/jxbrowser and click Download button. 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

  

2. Get License

To get free JxBrowser 30-days evaluation license please fill the web form and click Download Evaluation Key button. You will receive an email with a link that you can use to download evaluation license file — license.jar. Download the license.jar file and save it in 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            // Free 30-day evaluation license

 

3. Create Java Project

Create a new Java Project using your favorite IDE.


4. 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

5. Create HelloWorld Example

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

/*
 * Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
 * TeamDev PROPRIETARY and CONFIDENTIAL.
 * Use is subject to license terms.
 */

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 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>");
    }
} 

6. Run the Program

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