Compilation and use of Windows version of JCEF Embedded browser

Source: Internet
Author: User

Background

New requirements received at the end of last year need to make a web version of a feature in a desktop app that was originally made from swing, and be integrated into the original application, in other words, using an inline browser. The first consideration was the webview provided by JavaFX, the advantage being that no other third-party libraries were needed, and jdk1.7 began to integrate. However, after the completion of the development of two more serious problems, one is that the interface has a more complex graph will be serious lag, the other is a chance to cause the virtual machine crashes, and the speed is not very satisfying. Finally, we can only consider changing an inline browser frame, and then find Jcef, based on Chrome, the speed compatibility is very good.

About JCEF not much to introduce, do not know can poke here java-cef, this article mainly explains the JCEF compilation process, because the product only supports the Windows platform using the 32-bit JRE, so only the Win32 version, 64-bit compilation process is basically the same, only need to change the next parameter.

Compiling the environment
    • CMake 2.8.12.2 or newer version (I use the free version, the bin directory to manually configure environment variables)
    • Git
    • Visual Studio 2015 (recommended 2015, because developers use the 2015 version, measured VS2010 and VS2013 compilation will be error)
    • Java 1.8 32 bit (written on the official website is 1.7 or 1.8, in fact, using 1.7 to compile the Java section will have syntax errors, can modify the source evasion, we recommend 1.8, compile 64-bit version using 64-bit JDK)
    • Python 2.6 or newer version (Python3 not supported)
Compilation process

1. Source code Download

Use git will download JCEF source code, clone address: Https://bitbucket.org/chromiumembedded/java-cef.git, of course, can also download JCEF source code directly. It is recommended to use Git clone, because when using cmake build, you need to use the information of the current node in the file under the. git directory to build the Jcef_version.h header file, if it is not git Clone code, there is no git-related file compilation error, This should be possible by modifying the compilation script to circumvent, the information obtained through the Git file to write dead, not tried, not fine table.

    

2. CMake Build vs Engineering

Create a new directory under the source directory Jcef_build (not arbitrarily named), open DOS into the new directory, enter the command cmake-g "Visual Studio 14 2015":, enter to start building. Here is the pit, I made up when the VS2015 here error, found no compiler, studied long time finally found a sentence, VS2015 default installation does not include C + + support ... The whole people were not good at the time. If you want to make a 64-digit command, replace it with this: Cmake-g "Visual Studio Win64". 。 Another note here is that this process will automatically download the current JCEF corresponding CEF version, if the download is not successful can be downloaded and placed in the/JAVA-CEF/THIRD_PARTY/CEF directory. The CEF version number can be found from the CMakeLists.txt file in the source directory.

Cef:http://opensource.spotify.com/cefbuilds/index.html (often can not open, I fq to stable open)

CMake built-in C + + projects:

  

3. VS Build

Use vs to open the Jcef.sln file in Jcef_build, select "Build--Configuration Manager--Modify to release and Win32", and then choose Build-to-build solution and wait for the build to complete.

4. Compiling Java code

Use DOS to enter the tools directory of the source directory, execute the command compile.bat Win32

5. Test run

Also the tools directory, execute run.bat Win32 release Simple or Run.bat Win32 release detailed, the browser runs normally, compiles successfully.

6. Packaging

Tools directory to execute Make_distrib.bat Win32, the source directory will automatically create a package directory Binary_distrib, which contains the API documentation, browser demo, the use of the jar and DLL and resource files.

How to use

Jar to be used: the relevant jar package inside the \java-cef\binary_disrib\win32\bin

  

Dynamic libraries and resource files, etc.: \java-cef\binary_disrib\win32\bin\lib\win32 inside the content

Encoding when the import JCEF can be compiled successfully, run-time classpath Specify the jar package, the above DLL and other files Win32 directory, so the content in a directory, and then specify it as the value of-djava.library.path, you can refer to the \ Java-cef\binary_distrib\win32 inside the Run.bat.

One-click Compilation script

Build_jcef.bat Win32 A key compilation, the script is compiled according to 64-bit write, parameters with Win64 on the line, but the author did not try ...

@echo  on@REMSet PathSetSrc_path=d:\JAVA-CEFSetVs_path=c:\develop\VS2015if"%1" = = "" (EchoError:please Specify a target platform:win32 or Win64Set ERRORLEVEL=1Goto End)CD/D%src_path%mkdir%src_path%\Jcef_buildCD/d%src_path%\jcef_build@REMCMake ConstructionCmake-g "Visual Studio 14 2015":@REMvs Compilation@echoVS BuildingStart%vs_path%\common7\ide\devenv.exe%src_path%\jcef_build\jcef.sln/rebuild "release|%1"@echoVS BuildingEnd@REMcompiling the Java sectionCD/d%src_path%\ToolsPagerCompile.bat%1@REMPackingPagerMake_distrib.bat%1: EndExit/b
View Code

Conclusion

From compilation to development, as well as to solve a variety of BUG,JCEF data too little, go through a lot of detours. But the project is always a smooth completion of delivery, here to make a note, but also to share to the needs of the people, hoping to be helpful.

Compilation and use of Windows version of JCEF Embedded browser

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.