Get it correct the first time. The robust run-time type checking based on the strong Java type system combined with the advanced cross language type checks catches your mistakes early on.
Provides massive code reuse. J2CL closely follows the Java language semantics. This reduces surprises, enables reuse across different platforms and brings most popular Java libraries into your toolkit including Guava, Dagger and AutoValue.
Modern, fresh and blazing fast. Powered by Bazel, J2CL provides a fast and modern development experience that will make you smile and keep you productive.
Road tested and trusted. J2CL is the underlying technology of the most advanced GSuite apps developed by Google including GMail, Inbox, Docs, Slides and Calendar.
Clone the repository and build a sample app from source:
- Install Bazel 0.22.0:
$ npm install -g @firstname.lastname@example.org
(See Install Bazel for different platforms.)
- Clone this repository:
$ git clone https://github.com/google/j2cl.git
- Build a sample app:
$ cd j2cl/samples/helloworld $ bazel build src/main/java/com/google/j2cl/samples/helloworld:helloworld
- Look at the optimized output:
$ cat bazel-bin/src/main/java/com/google/j2cl/samples/helloworld/helloworld.js document.write('Hello from Java! and JS!');
ibazel is file-system watcher that auto-triggers bazel build when neeeded.
To use it, just replace
ibazel in any command:
Install ibazel and make sure it is in your path.
Run the development server
$ cd j2cl/samples/helloworld $ ibazel run src/main/java/com/google/j2cl/samples/helloworld:helloworld_dev_server
Navigate to 'http://localhost:6006/helloworld_dev.html" in your browser.
Edit any source (e.g.
HelloWorld.java), save and see the results. You will enjoy it more as it warms up!
You like build-on-save but you would like to refresh on your own terms?
-nolive_reload while running ibazel.
Setting up your first project
To start your first project, you can use the helloworld sample as a template:
$ cp -R <j2cl-repo>/samples/helloworld <my-repo>/<app-name>
and you are done.
- Please subscribe to J2CL announce for announcements (low traffic).
- Please report bugs or file feature requests via issue tracker.
- For other questions you can also use the issue tracker for now.
J2CL is production ready and actively used by many of Google's products, but the process of adapting workflows and tooling for the open-source version is not yet finalized and breaking changes will most likely be introduced.
We are actively working on adapting more pieces including Junit4 emulation and faster pruning for an even better development experience.
Last, the workflow is not yet supported in Windows. You can contribute to make this a reality. Coordinate and follow the progress of this effort here. For developers that want to use Windows as their platform we recommend installing under WSL (Windows Subsystem for Linux).
J2CL vs. GWT?
In early 2015, Google GWT team made a difficult but necessary decision to work on a new alternative product to enable Java for the Web.
It was mostly due to changing trends in the web ecosystem and our new internal customers who were looking at Java on the Web not as an isolated ecosystem but an integral part of their larger stack. It required a completely new vision to create tools from the ground up, that are tightly integrated with the rest of the ecosystem. A modern architecture, that is reliable, fast and provides a quick iteration cycle.
There was no practical way to achieve those goals completely incrementally out of GWT. We started from scratch using everything we learned from working on GWT over the years. In the meantime, we kept GWT steering committee members in the loop and gave contributors very early access so they could decide to build the next version of GWT on J2CL.
The strategy has now evolved GWT3 to an SDK focused on libraries and enterprise tooling which was one of the strongest points of GWT all along.
We think that such separation of concerns is crucial part of the success of the both projects and will provide the best results for the open source community.
Read how to contribute to J2CL.
Please refer to the license file.
J2CL is not an official Google product and is currently in 'alpha' release for developer preview.