(Auto)Release of J(ava)Query!
Today is a great day. With a huge delight the DukeScript project announces that it is now easy to use JQuery in your DukeScript applications. What is so great on that? Maybe you are thinking: “ooh well, just another library” and you might be right. However this time the situation is different: the Java APIs for the library haven’t been written manually, they have been auto-generated. This way it is possible to create Java APIs for any JavaScript library!
First of all, let’s look at the JavaQuery - e.g. Java APIs for JQuery:
here is the package javadoc
and here is the dependency to the Maven artifact which
is now available on Maven Central
and should be included in your pom.xml
file:
Once you include this library in your application (follow getting started
tutorial to create an empty one), you can start using JQuery from Java. Create
index.html
:
and you can use following code to control it via JQuery for Java API:
Looks familiar? Yes, the code mimics the JavaScript one as closely as possible. However it brings all the Java benefits: strong type checks, proper code completion, all the goodies of Java tooling ecosystem.
Structure of the JQuery API
The JQuery API for Java
as well as any other API produced this way follows the same pattern. The
central place of the API is Exports class
which contains all the global symbols and ways to invoke them the JavaScript
library provides. In case of JQuery the exported symbols are $
and jQuery
. The best way to
use such library is to do a static import of the symbol(s):
At that moment one can use $
as an entry point into other
JQuery library API classes.
Using JavaScript libraries from Java has never been easier!
Testing
First of all thanks for all your support of DukeScript. However,
would you mind to support the project a bit more? If so, please try to use
the JQuery API for Java
a bit and share your experience with us - either in the comments section,
at the DukeScript forum
or directly. While the current version 0.2
seems to work, testing it on more complex samples is important. Thank you for your help!