Skip to content
forked from kylestev/jvm.js

A Java VM bytecode library written in ES6 for Node.js

License

Notifications You must be signed in to change notification settings

Hotallday/jvm.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jvm.js

A bytecode library for Java written in Node.js

npm version

This module is under active development and has not yet reached even a v0.1 release. This module will be following SemVer once it is ready for use by 3rd parties.


Installation

$ npm install jvm

And you will be able to get started with using jvm.js. Take a look at the next section for some examples of how to get started.

Examples

jvm.js makes use of Promises instead of passing callbacks in functions. This allows your code to not fall victim to the node callback tree of doom. You'll see examples of it in the examples below.

If you're unfamiliar with Promises, or need a refresher, checkout Mozilla's excellent documentation here.

Loading a Jar's classes

The example below uses ES6 and shows how easy it is to parse a Jar file.

import { Jar } from 'jvm';

Jar.unpack('./test.jar')
  .then((jar) => {
    for (let [name, cls] of jar) {
      if (cls.name === 'client') {
        console.log('found client class!');
        console.log(JSON.stringify({
          name: cls.name,
          superName: cls.superName,
          methodCount: cls.methods.length,
          fieldCount: cls.fields.length
        }, null, 2));
      }
    }
  })
  .catch(console.error.bind(console));

About

A Java VM bytecode library written in ES6 for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%