Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.

JxBrowser is based on Chromium engine. There are lots of command lines (switches) which can be used with Chromium. Some change behavior of features, others are for debugging or experimenting.

JxBrowser provides API that allows configuring Chromium with command line switches. The list of command line switches you can provide before you create any Browser instance. The following code demonstrates how to do it:  


 The following sample demonstrates how to disable web security and allow file access from HTML via appropriate Chromium switches: 

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>

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

 * The sample demonstrates how to enable access to local files from a web page.
public class LoadLocalFilesSample {
    public static void main(String[] args) {
        BrowserPreferences.setChromiumSwitches("--disable-web-security", "--allow-file-access-from-files");

        Browser browser = new Browser();
        BrowserView browserView = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.add(browserView, BorderLayout.CENTER);
        frame.setSize(700, 500);

        browser.loadHTML("<html><body>Image:<img src='file:///C:\\image.jpg'></body></html>");