GithubHelp home page GithubHelp logo

wulin-challenge / jcefmaven Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jcefmaven/jcefmaven

0.0 1.0 0.0 821 KB

Maven artifacts for JCef

License: Apache License 2.0

Shell 13.97% Java 82.38% HTML 3.47% Dockerfile 0.18%

jcefmaven's Introduction

JCEF MAVEN

build-all Maven Central

Independent project to produce maven artifacts for the JCef project

Visit the JCEF repo at bitbucket or github
browser
Embed a complete browser in your Java Apps - supports Java 8+

Supports

linuxamd64, arm64, arm
windowsamd64, arm64, i386
macosxamd64, arm64

Installation

Use with Maven:

<dependency>
    <groupId>me.friwi</groupId>
    <artifactId>jcefmaven</artifactId>
    <version>110.0.25</version>
</dependency>

Use with Gradle:

implementation 'me.friwi:jcefmaven:110.0.25'

How to use

You can find the most recent versions of the artifacts on the releases page of this repository. Alongside each release is also a table with platforms that have been tested. If you have tested a platform and build combination that has not been tested before (using the sample app), make sure to open a new issue to share your findings!

Once you found a version you want to use, include it as a dependency into your project. An example include for Maven and Gradle can be seen above. This will only include the base jcef library and jogl in your project. Natives will be downloaded and extracted on first run. If you want to skip downloading and instead bundle the natives, include the native artifacts in your project dependencies. You can see all of them here. It is recommended to only include one bundle per build though, as each bundle is ~100MB. If you wish to include them, make sure you export one build per platform!

Once you added your dependencies, you need to fire up jcefmaven in your code. No worries, it's not complicated!

//Create a new CefAppBuilder instance
CefAppBuilder builder = new CefAppBuilder();

//Configure the builder instance
builder.setInstallDir(new File("jcef-bundle")); //Default
builder.setProgressHandler(new ConsoleProgressHandler()); //Default
builder.addJcefArgs("--disable-gpu"); //Just an example
builder.getCefSettings().windowless_rendering_enabled = true; //Default - select OSR mode

//Set an app handler. Do not use CefApp.addAppHandler(...), it will break your code on MacOSX!
builder.setAppHandler(new MavenCefAppHandlerAdapter(){...});

//Build a CefApp instance using the configuration above
CefApp app = builder.build();

From there, continue to write your app using jcef as you are used to. You can call builder.build() as many times as you want. It is even thread-safe while initializing (will pause threads and return when initialization was completed).

You can also set your custom download mirrors by using the getMirrors() and setMirrors(Collection<String>) methods. This currently defaults to this repository on github.com and alternatively to the central maven repo on repo.maven.apache.org. Further information can be found in the javadoc.

If you need some code examples to create your first app, have a look at the tests on this repository or at the sample app.

Some additional useful code snippets

If you want to get the current platform as determined by jcefmaven (e.g. to disable osr on win-arm64), you can use:

EnumPlatform platform = EnumPlatform.getCurrentPlatform();
EnumOS os = platform.getOs();

If you want to obtain version information, you can use:

//Provides build version data. Requires build_meta.json to be on classpath.
CefBuildInfo buildInfo = CefBuildInfo.fromClasspath();

//Provides JCEF version data. You can call this after initialization.
CefVersion cefVersion = cefApp.getVersion();

Requirements

  • Java 8 or later

Limitations

  • No OSR mode supported on win-arm64 (no jogamp)
  • CefApp.addAppHandler(...) should not be used. Use builder.setAppHandler(...) instead (requires a CefMavenAppHandlerAdapter)
  • To run on JDK 16 or later:

To use on MacOSX, add the following JVM flags:

--add-opens java.desktop/sun.awt=ALL-UNNAMED
--add-opens java.desktop/sun.lwawt=ALL-UNNAMED
--add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED

To use OSR (off-screen render) mode, add these flags for JOGL:

--add-exports java.base/java.lang=ALL-UNNAMED
--add-exports java.desktop/sun.awt=ALL-UNNAMED
--add-exports java.desktop/sun.java2d=ALL-UNNAMED

Reporting bugs

Please only report bugs here that are related to the maven artifacts. Please report bugs in JCEF/CEF to the corresponding repository on Bitbucket.

jcefmaven's People

Contributors

friwidev avatar jasonsparc avatar jjlauer avatar hax0r31337 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.