{"id":15045733,"url":"https://github.com/j4ts/j4ts","last_synced_at":"2025-08-19T14:32:40.050Z","repository":{"id":5511943,"uuid":"53338195","full_name":"j4ts/j4ts","owner":"j4ts","description":"Core Java APIs for TypeScript / JavaScript / JSweet","archived":false,"fork":false,"pushed_at":"2022-09-18T14:01:20.000Z","size":3652,"stargazers_count":98,"open_issues_count":14,"forks_count":24,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-07T14:51:35.720Z","etag":null,"topics":["gwt","java","java-api","javascript","jsweet","typescript"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j4ts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-07T15:57:35.000Z","updated_at":"2024-12-07T13:35:25.000Z","dependencies_parsed_at":"2022-08-06T18:16:33.081Z","dependency_job_id":null,"html_url":"https://github.com/j4ts/j4ts","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j4ts%2Fj4ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j4ts%2Fj4ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j4ts%2Fj4ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j4ts%2Fj4ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j4ts","download_url":"https://codeload.github.com/j4ts/j4ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230359935,"owners_count":18214157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gwt","java","java-api","javascript","jsweet","typescript"],"created_at":"2024-09-24T20:52:13.274Z","updated_at":"2024-12-19T01:07:32.408Z","avatar_url":"https://github.com/j4ts.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# J4TS\nJava APIs for TypeScript / JavaScript / JSweet\n\nJ4TS 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](https://github.com/cincheo/jsweet/). It intends to be useful for the following cases:\n\n- Programmers used to the Java APIs can be more efficient using J4TS than when having to learn basic JavaScript APIs.\n- 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).\n- 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](https://github.com/cincheo/jsweet/), but it is not limited to it.\n\nJ4TS 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](https://github.com/MikeMcl/bignumber.js/) for instance). \n\nJ4TS is intended to be completed on-the-fly as more use cases are needed. So feel free to contribute.\n\n## Examples\n```TypeScript\nimport List = java.util.List;\nimport ArrayList = java.util.ArrayList;\nimport Set = java.util.Set;\nimport HashSet = java.util.HashSet;\nimport Map = java.util.Map;\nimport HashMap = java.util.HashMap;\n\nvar l: List\u003cString\u003e = new ArrayList\u003cString\u003e();\nl.add(\"a\");\nl.add(\"b\");\nl.add(\"c\");\nassertEquals(\"[a, b, c]\", l.toString());\nassertEquals(l.indexOf(\"a\"), 0);\n\nvar s: Set\u003cString\u003e = new HashSet\u003cString\u003e();\ns.add(\"a\");\ns.add(\"a\");\ns.add(\"b\");\ns.add(\"c\");\ns.add(\"c\");\nassertEquals(3, s.size());\nassertTrue(s.contains(\"c\"));\n\nvar s: Map\u003cString, String\u003e = new HashMap\u003cString, String\u003e();\ns.put(\"a\", \"aa\");\ns.put(\"b\", \"bb\");\ns.put(\"c\", \"cc\");\nassertEquals(\"bb\", s.get(\"b\"));\n```\n\n## How to use\n\nYou can use the current JavaScript bundle (JSweet-generated runtime): ``dist/j4ts.js``. \n\nFrom TypeScript, you can compile with: ``dist/j4ts.d.ts``.\n\nFrom JSweet, add the candy dependency in your ``pom.xml``.\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003eorg.jsweet\u003c/groupId\u003e\n\t\u003cartifactId\u003ej4ts\u003c/artifactId\u003e\n\t\u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nA simple and still incomplete test suite is available [there](https://github.com/cincheo/j4ts/blob/master/src/main/java/test/Test.java). Make sure that the tests pass by opening [index.html](https://github.com/cincheo/j4ts/blob/master/index.html).\n\n## How to modify/package\n\nYou can compile, package and install the J4TS candy in your local Maven repository by running Maven in the project's directory:\n\n```\n\u003e mvn install\n```\n\n## Disclaimer\n\nJ4TS 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.\n\n## Contributions\n\nJ4TS 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.\n\n## License\n\nJ4TS is licensed under the Apache Open Source License version 2.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj4ts%2Fj4ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj4ts%2Fj4ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj4ts%2Fj4ts/lists"}