-
Notifications
You must be signed in to change notification settings - Fork 11
The WebAPI package
The SnapKit WebAPI package provides a set of WebAPI wrapper classes that are a bridge to the browser WebAPIs. This allows Java developers to directly manipulate the DOM when running in the browser. SnapKit itself uses this package in the browser to get native graphics acceleration, 3D and more.
To get Java back in the UI game the value must be high and costs low. The ideal modern Java UI framework should include these features:
- Run in browser and desktop
- Leverage familiarity and ubiquity of browser programming
- Support modern graphics, audio, video, animation and 3D
- Interoperable with other end user technologies and services
- Leverage skills most front-end developers have and want
- Not require years of development and excessive funding
If you accept any of that, then it follows that Java UI should fundamentally be built on Web API. There is no need to rewrite this vast functionality, Web APIs are readily available everywhere: in every browser and on the desktop via Chrome packaging. Web APIs are the new "AWT" - and Java doesn't have to play an impossible game of catch up.
Here are some demos of Java Web API in action, running in a Java IDE (SnapCode) that is itself running on WebAPI:
- Browser DOM Demos: https://reportmill.com/SnapCode/app/#sample:DOMTests.zip
And to see a preliminary demo of SnapCode running on the desktop and using Chrome as the windowing, rendering and runtime, download jbang and run SnapCode with this simple command:
- Desktop app:
jbang snapcodejx@reportmill
This uses the JxBrowser framework to easily interface with Chrome. There has only been about a week of development on this and our evaluation license runs out soon. But we hope to add polish and figure out a JxBrowser licensing solution once the project generates more interest.
Since the WebAPI framework is a wrapper, it needs access to a real WebAPI implementation. In the browser, this can be done with CheerpJ. On the desktop, this can be done with the JxBrowser library. This project contains an adapter for each of those environments.
To run this library in the browser with CheerpJ:
- ./gradlew build
- Copy cjdom.js and cjdom.html to build/libs dir
- Run some http-server in that directory
- Go to http://localhost:8080/cjdom.html in your browser
To use this library on the desktop with JxBrowser:
- Edit build.gradle
- Uncomment jxbrowser dependency for platform
- This is one of: mac, win, mac-arm, win-arm or linux
You will also need to get a JxBrowser key from the JxBrowser people by clicking on the "Try for free" link.