{"id":25472,"library":"esjava","title":"ESJava","description":"ESJava (v0.0.8) is an experimental transpiler that converts Java source code to ES6 (ES2015) JavaScript. It targets ES6 features such as classes, arrow functions, and static getters. Release cadence is low; the project has not seen updates since 2016. Compared to other Java-to-JS tools like GWT or J2CL, ESJava is a lightweight, single-pass transpiler focused on syntactic translation without runtime libraries. It is primarily a proof-of-concept for converting small Java programs, with limited support for Java standard library or advanced language features.","status":"abandoned","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/mazko/ESJava","tags":["javascript","java","transpiler","es6"],"install":[{"cmd":"npm install esjava","lang":"bash","label":"npm"},{"cmd":"yarn add esjava","lang":"bash","label":"yarn"},{"cmd":"pnpm add esjava","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used for CLI argument parsing","package":"commander","optional":false}],"imports":[{"note":"ESJava provides ES modules; CommonJS require is not officially supported and may fail if using the default npm build without transpilation.","wrong":"const esjava = require('esjava')","symbol":"esjava","correct":"import esjava from 'esjava'"},{"note":"The named export 'compile' is available in ES module mode only.","wrong":"const compile = require('esjava').compile","symbol":"compile","correct":"import { compile } from 'esjava'"}],"quickstart":{"code":"import { compile } from 'esjava';\n\nconst javaCode = `\npublic class Hello {\n    public static void main(String[] args) {\n        System.out.println(\"Hello, world!\");\n    }\n}\n`;\n\nconst jsCode = compile(javaCode);\nconsole.log(jsCode);\n// Output:\n// 'use strict';\n// class Hello {\n//   static main(args) {\n//     console.log(\"Hello, world!\");\n//   }\n// }","lang":"javascript","description":"Demonstrates converting a simple Java class with a main method to ES6 JavaScript using the compile function."},"warnings":[{"fix":"Consider using modern alternatives like J2CL or TeaVM for production use.","message":"Package has not been updated since 2016 and is effectively abandoned.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Avoid using Java standard library classes that are not ES6 equivalents; manually implement or polyfill missing functionality.","message":"Only supports a subset of Java 8 features; many standard library classes (e.g., java.util) are not transpiled and will cause runtime errors.","severity":"gotcha","affected_versions":"<=0.0.8"},{"fix":"Be aware that static final fields are not truly immutable across subclasses; use Object.defineProperty for stricter immutability if needed.","message":"Static final fields are transpiled to ES6 getters, which are read-only but can be overridden in subclasses, differing from Java's final behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the programmatic API (import { compile } from 'esjava') instead of the CLI.","message":"The CLI tool uses an older version of commander; command-line usage may not work with recent Node.js versions.","severity":"deprecated","affected_versions":"<=0.0.8"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the package: npm install esjava. If using require, switch to import or use dynamic import().","cause":"Package not installed or installed but using CommonJS require with an ESM-only package.","error":"Error: Cannot find module 'esjava'"},{"fix":"Use import instead of require, or set type: module in package.json.","cause":"Trying to require an ES module with CommonJS require.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}