How to integrate Chromium Embedded Framework (CEF) with java
Solution 1
Is it possible to embed CEF/JCEF in java application?
Yes, you can do that! The steps are:
-
Download JCEF and extract it JCEF
-
Declare Environment Variable to point to
${EXTRACT_DIR}/bin/lib/win64
-
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
-
Create a maven project and declare installed artifacts in pom.xml
-
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
Solution 2
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.
Solution 3
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
Related videos on Youtube
Comments
-
Amogh almost 3 years
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?
-
Czarek Tomczak over 10 yearsYour best chance for getting an answer is on the CEF Support Forum. 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.
-
thouliha almost 9 years@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.
-
Czarek Tomczak almost 9 years@thouliha See the Quick Links section and the Tutorial wiki page here: bitbucket.org/chromiumembedded/cef . See also other wiki pages: bitbucket.org/chromiumembedded/cef/wiki/browse
-
gumuruh over 7 yearsis it still having a lot of bugs? I saw the bitbucket.org comments over there....
-
-
Amogh almost 10 yearsI am also working on the same JCEF as I posted in answer. I will surprise if there is any 32bit version.
-
Tho almost 10 yearsNo, JCEF also supports JVM 32 bit but it may not be tested carefully code.google.com/p/javachromiumembedded/wiki/BranchesAndBuilding
-
Admin over 9 yearsHi, I m trying to set up/build JCEF in eclipse. Please share steps to do so? You can post answer here stackoverflow.com/questions/25761607/…
-
thouliha almost 9 yearsI'm trying to get it working for linux, which files do i use?
-
Vigs over 8 yearsIn step 2, "Declare Environment Variable", can you explain in more detail? What environment variable are we declaring?
-
Tho over 8 yearsPlease check out this link en.m.wikipedia.org/wiki/Environment_variable . You could simple append the path to PATH variable
-
Vigs over 8 yearsThanks. 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 to build JCEF.
-
Vigs over 8 yearsI 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. -
smac89 almost 4 years@toolforger why do you say that?
-
toolforger almost 4 yearsAh... wait... I confused this with Maven Central availability. Sorry.
-
dazza5000 over 3 yearsI wrote a very brief article on how to get started with the releases mentioned above whereisdarran.com/2020/12/…
-
smac89 over 3 years@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
-
René Pöpperl over 2 yearsPlease, 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 namedjava-cef-build-bin
. -
smac89 over 2 years@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.