All Projects → j4ts → j4ts

j4ts / j4ts

Licence: Apache-2.0 license
Core Java APIs for TypeScript / JavaScript / JSweet

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to j4ts

jvm-alternatives-to-js
Repository comparing JVM alternatives to JS: CheerpJ, GWT, JSweet, TeaVM, Vaadin Flow, bck2brwsr (bonus: React, Dart)
Stars: ✭ 24 (-73.91%)
Mutual labels:  gwt, jsweet
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (-26.09%)
Mutual labels:  java-api
Vue Gwt
Vue.js Components/Custom Elements in Java with GWT. Developed at https://www.genmymodel.com.
Stars: ✭ 194 (+110.87%)
Mutual labels:  gwt
compare-utils
Compares of Java Collections and Objects (of different classes) made easy
Stars: ✭ 15 (-83.7%)
Mutual labels:  java-api
MilightAPI
A java API for MiLight light bulbs. Other brands of light bulbs are also compatible, for instance EasyBulb, LimitlessLED, etc.
Stars: ✭ 28 (-69.57%)
Mutual labels:  java-api
active-persistence
Active Persistence is a implementation of Active Record Query Interface for JPA that makes it easy and fun.
Stars: ✭ 14 (-84.78%)
Mutual labels:  java-api
Dashbuilder
Dashboard composition tooling based on the Uberfire framework
Stars: ✭ 163 (+77.17%)
Mutual labels:  gwt
tiff-java
Tagged Image File Format Java Library
Stars: ✭ 65 (-29.35%)
Mutual labels:  java-api
testlink-java-api
TestLink Java API
Stars: ✭ 62 (-32.61%)
Mutual labels:  java-api
japi
Used to generate a beautiful API Java document
Stars: ✭ 103 (+11.96%)
Mutual labels:  java-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (-63.04%)
Mutual labels:  java-api
yahoo-weather-java-api
A Java API for the yahoo weather service
Stars: ✭ 26 (-71.74%)
Mutual labels:  java-api
travels-java-api
An API for travel management. It is built with Java, Spring Boot, and Spring Framework. A toy-project to serve as a theoretical basis for the Medium series of articles I wrote about Java+Spring.
Stars: ✭ 139 (+51.09%)
Mutual labels:  java-api
Swellrt
SwellRT main project. Server, JavaScript and Java clients
Stars: ✭ 205 (+122.83%)
Mutual labels:  gwt
Useful Java Links
A list of useful Java frameworks, libraries, software and hello worlds examples
Stars: ✭ 5,126 (+5471.74%)
Mutual labels:  java-api
Bitcoin Transaction Explorer
Simple and pure block explorer you can run on top of a full node
Stars: ✭ 165 (+79.35%)
Mutual labels:  gwt
google-search-results-java
Google Search Results JAVA API via SerpApi
Stars: ✭ 18 (-80.43%)
Mutual labels:  java-api
wbp4j
Simple Java Api for 微博图床,使用简单的api即可完成上传图片
Stars: ✭ 48 (-47.83%)
Mutual labels:  java-api
domino-jackson
Jackson with Annotation processing
Stars: ✭ 46 (-50%)
Mutual labels:  gwt
picocog
A tiny code generation library (< 8 KB) written in Java, useful for any purpose, but ideal for JSR-269
Stars: ✭ 82 (-10.87%)
Mutual labels:  gwt

J4TS

Java APIs for TypeScript / JavaScript / JSweet

J4TS is based on a fork of the GWT's JRE emulation library and is written in Java, and transpiled to TypeScript/JavaScript with the JSweet transpiler. It intends to be useful for the following cases:

  • Programmers used to the Java APIs can be more efficient using J4TS than when having to learn basic JavaScript APIs.
  • It can ease code sharing between Java and TypeScript/JavaScript (and also hopefully, ease the understanding and relationships between the Java fans and TypeScript/JavaScript ones).
  • Typically, J4TS can be used as a runtime for transpilers, so that you can use the Java APIs in your transpiled Java programs. So far, J4TS main target is the JSweet transpiler, but it is not limited to it.

J4TS currently covers most of the core Java API supported by GWT (java.lang, java.util, some java.io). It does not support java.math yet because the GWT implementation requires a deep Java emulation, which is not consistent with the JSweet approach (so java.math should be implemented as a wrapper for bignumber.js for instance).

J4TS is intended to be completed on-the-fly as more use cases are needed. So feel free to contribute.

Examples

import List = java.util.List;
import ArrayList = java.util.ArrayList;
import Set = java.util.Set;
import HashSet = java.util.HashSet;
import Map = java.util.Map;
import HashMap = java.util.HashMap;

var l: List<String> = new ArrayList<String>();
l.add("a");
l.add("b");
l.add("c");
assertEquals("[a, b, c]", l.toString());
assertEquals(l.indexOf("a"), 0);

var s: Set<String> = new HashSet<String>();
s.add("a");
s.add("a");
s.add("b");
s.add("c");
s.add("c");
assertEquals(3, s.size());
assertTrue(s.contains("c"));

var s: Map<String, String> = new HashMap<String, String>();
s.put("a", "aa");
s.put("b", "bb");
s.put("c", "cc");
assertEquals("bb", s.get("b"));

How to use

You can use the current JavaScript bundle (JSweet-generated runtime): dist/j4ts.js.

From TypeScript, you can compile with: dist/j4ts.d.ts.

From JSweet, add the candy dependency in your pom.xml.

<dependency>
	<groupId>org.jsweet</groupId>
	<artifactId>j4ts</artifactId>
	<version>VERSION</version>
</dependency>

A simple and still incomplete test suite is available there. Make sure that the tests pass by opening index.html.

How to modify/package

You can compile, package and install the J4TS candy in your local Maven repository by running Maven in the project's directory:

> mvn install

Disclaimer

J4TS is not a Java emulator and is not made for fully implementing the Java semantics in JavaScript. It is close to and mimics Java behavior, but it will never be completely Java. For instance, primitive types in Java and JavaScript are quite different (chars and numbers especially) and we don't want to emulate that difference.

Contributions

J4TS is meant to serve the public interest and be as open as possible. So anyone is more than welcome to contribute as long as it does not deviate J4TS from its initial goals stated above. When you meet a class or a method that is not supported, please feel free to contribute under the terms of the license.

License

J4TS is licensed under the Apache Open Source License version 2.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].