24

I'd like to make a desktop application to let a website be browsed, I don't want to make a browser but a Browser embeded Application. I've tried with JavaFx but I've found some problems like missing support for plugins (eg: flash, pdf viewer, etc).

After lots of search i found Chromium Embedded Framework (CEF) or JCEF Java wrapper for CEF but i don't know how to use it in java to start with.What are the dependencies?How i can start development (POC) using netbeans?

Is it possible to embed CEF/JCEF in java application?

Mrinal
  • 396
  • 1
  • 4
  • 12
Amogh
  • 4,453
  • 11
  • 45
  • 106
  • Your best chance for getting an answer is on the [CEF Support Forum](http://www.magpcss.org/ceforum/viewforum.php?f=6). Recently, Marshall the founder of CEF, took over the JCEF project. So feel free to ask questions on the CEF Forum. Post a link to the topic after you ask there. – Czarek Tomczak Jan 18 '14 at 11:16
  • 5
    @CzarekTomczak that forum is horrendous. Why is there no quickstart for this? It just gives you a download page, and tells you nothing about how to get the binaries working. – dessalines Jun 11 '15 at 18:23
  • 1
    @thouliha See the Quick Links section and the Tutorial wiki page here: https://bitbucket.org/chromiumembedded/cef . See also other wiki pages: https://bitbucket.org/chromiumembedded/cef/wiki/browse/ – Czarek Tomczak Jun 11 '15 at 18:38
  • is it still having a lot of bugs? I saw the bitbucket.org comments over there.... – gumuruh Jan 26 '17 at 07:30

3 Answers3

20

Is it possible to embed CEF/JCEF in java application?

Yes, you can do that! The steps are:

  1. Download JCEF and extract it JCEF

  2. Declare Environment Variable to point to ${EXTRACT_DIR}/bin/lib/win64

  3. Install following files in local repository: ${EXTRACT_DIR}/bin/{gluegen-rt.jar, gluegen-rt-natives-windows-amd64.jar, jogl-all.jar, jogl-all-natives-windows-amd64.jar, jcef.jar}.

For example: mvn install:install-file -Dfile=gluegen-rt.jar -DgroupId=org.jcef -DartifactId=gluegen -Dversion=1.0 -Dpackaging=jar

  1. Create a maven project and declare installed artifacts in pom.xml

  2. Copy sample: ${EXTRACT_DIR}/bin/tests/simple/MainFrame.java to your project and try it

Take note that those steps are for Maven Project and JVM 64bit

Tho
  • 23,158
  • 6
  • 60
  • 47
  • I am also working on the same JCEF as I posted in answer. I will surprise if there is any 32bit version. – Amogh Jul 26 '14 at 14:32
  • 2
    No, JCEF also supports JVM 32 bit but it may not be tested carefully https://code.google.com/p/javachromiumembedded/wiki/BranchesAndBuilding – Tho Jul 26 '14 at 15:37
  • Hi, I m trying to set up/build JCEF in eclipse. Please share steps to do so? You can post answer here http://stackoverflow.com/questions/25761607/setting-up-cef-development-in-eclipse-for-java –  Sep 10 '14 at 14:56
  • I'm trying to get it working for linux, which files do i use? – dessalines Jun 11 '15 at 18:27
  • In step 2, "Declare Environment Variable", can you explain in more detail? What environment variable are we declaring? – Vigs Dec 20 '15 at 02:34
  • Please check out this link https://en.m.wikipedia.org/wiki/Environment_variable . You could simple append the path to PATH variable – Tho Dec 20 '15 at 04:36
  • Thanks. Sorry I should have been more specific. I understand what a environment variable does and how to use them. But in this specific case I do not understand why we are adding the the ${extract_dir} to our path? Furthermore, your instructions seem to be a it unclear as the download on the link your provided don't seem to include JCEF. I had to follow instructions [here](https://bitbucket.org/chromiumembedded/java-cef/wiki/BranchesAndBuilding) to build JCEF. – Vigs Dec 20 '15 at 15:20
  • 3
    I understand why we need the native code added to the path now. For others who stumble on this: In `CefApp.java`, jcef tries to load the libcef and jawt libraries, which exist in the output dir of the native cef build. We must make those libs discoverable by adding that directory to the systems path. – Vigs Dec 20 '15 at 17:38
17

I have a repository that maintains releases for each version of JCEF. The builds are done for different architectures and OS (mac, linux, and windows).

https://github.com/jcefbuild/jcefbuild/releases

Depending on your target OS and architecture, each zip contains jars which need to be placed on the classpath of your java application. They also contain native libraries which need to be loaded by your application by setting java.library.path to point to the folder containing the binaries.

The zips also contain a test application which can be executed by running a script also found in the folder.

smac89
  • 39,374
  • 15
  • 132
  • 179
  • @toolforger why do you say that? – smac89 Jun 11 '20 at 13:29
  • Ah... wait... I confused this with Maven Central availability. Sorry. – toolforger Jun 11 '20 at 14:07
  • 2
    I wrote a very brief article on how to get started with the releases mentioned above http://whereisdarran.com/2020/12/getting-started-with-java-cef-on-linux/ – dazza5000 Dec 05 '20 at 21:28
  • @dazza5000 that's great. Short and sweet. I haven't had time to create maven jars for full Java development, but I will make sure to ping your comment when that's ready – smac89 Dec 05 '20 at 21:46
  • Please, please, please add some documentation to you jcefbuild repo. I can't find information on how to get started with it. The blog entry of @dazza5000 isn't valid anymore. I can't find a `run.sh` file and I also can't find a folder named `java-cef-build-bin`. – René Pöpperl Nov 19 '21 at 08:12
  • 2
    @RenéPöpperl I must admit, it has been a long time since I touched that project, been soo busy with other things. All the releases you see are being done by travis ci, and appveyor (all automatically). I can't promise, but I'll see if there is an easy fix to the issues you mentioned, then I will update the repo by the end of the week. – smac89 Nov 19 '21 at 14:54
  • what if each release is added with the notes of which version of chrome engine support (w/o crashes) too... at least it will help the new users who wants to implements jcef – gumuruh Feb 11 '23 at 23:39
2

You can embed CEF in Java applications by using the open source project Chromium SWT:

https://github.com/equoplatform/chromium-swt

It works on SWT applications. You can use it by adding an import sentence to your app and creating an instance of the Chromium widget.

Since you want to create a desktop app using Java, I also recommend to take a look at Equo Framework, which allows to create desktop applications from scratch, using java and HTML5 technologies for the frontend. Please find the link below:

https://github.com/equoplatform/framework

Dharman
  • 30,962
  • 25
  • 85
  • 135
Juan
  • 21
  • 1