Registry / web-framework / esjava

esjava

JSON →
library0.0.8jsnpmunverified

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.

npm install esjava
INSTALL
IMPORT
SIG · ESJAVA
E
esjava
web-frameworkjavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

esjava
import esjava from 'esjava'
const esjava = require('esjava')
ESJava provides ES modules; CommonJS require is not officially supported and may fail if using the default npm build without transpilation.
compile
import { compile } from 'esjava'
const compile = require('esjava').compile
The named export 'compile' is available in ES module mode only.

Demonstrates converting a simple Java class with a main method to ES6 JavaScript using the compile function.

import { compile } from 'esjava'; const javaCode = ` public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } } `; const jsCode = compile(javaCode); console.log(jsCode); // Output: // 'use strict'; // class Hello { // static main(args) { // console.log("Hello, world!"); // } // }
esjava --version
Debug
Known issues
deprecatedPackage has not been updated since 2016 and is effectively abandoned.
fix
Consider using modern alternatives like J2CL or TeaVM for production use.
affects: >=0.0.0
gotchaOnly supports a subset of Java 8 features; many standard library classes (e.g., java.util) are not transpiled and will cause runtime errors.
fix
Avoid using Java standard library classes that are not ES6 equivalents; manually implement or polyfill missing functionality.
affects: <=0.0.8
gotchaStatic final fields are transpiled to ES6 getters, which are read-only but can be overridden in subclasses, differing from Java's final behavior.
fix
Be aware that static final fields are not truly immutable across subclasses; use Object.defineProperty for stricter immutability if needed.
affects: >=0.0.0
deprecatedThe CLI tool uses an older version of commander; command-line usage may not work with recent Node.js versions.
fix
Use the programmatic API (import { compile } from 'esjava') instead of the CLI.
affects: <=0.0.8
Errors
Common errors & fixes
Error: Cannot find module 'esjava'
Package not installed or installed but using CommonJS require with an ESM-only package.
fix
Install the package: npm install esjava. If using require, switch to import or use dynamic import().
SyntaxError: Unexpected token 'export'
Trying to require an ES module with CommonJS require.
fix
Use import instead of require, or set type: module in package.json.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies
commanderrequiredused for CLI argument parsing
Agent activity
4 hits · last 30 days
node
4
Resources
esjava — npm install esjava · libregistry