Node.js Nailgun Client

0.1.2 · abandoned · verified Tue Apr 21

node-nailgun-client provides a Node.js API and command-line interface (CLI) for interacting with a Nailgun server. Nailgun is a system designed to run Java programs from the command line without incurring the typical JVM startup overhead, acting as a long-running JVM server that executes commands sent from a client. This package allows Node.js applications to programmatically execute Java code via the Nailgun protocol. The current and only stable version is 0.1.2, last published over seven years ago. The package's development is abandoned, coinciding with the upstream Nailgun project itself being officially unmaintained since April 2023. Key differentiators included its attempt to integrate high-performance Java execution within Node.js workflows by leveraging Nailgun's persistent JVM model.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to execute a basic Nailgun command and a custom Java class with arguments and server configuration, handling I/O streams and exit codes.

const nailgunClient = require('node-nailgun-client');

// Basic execution of a Nailgun command (e.g., 'ng-stats' for server status)
const simpleNail = nailgunClient.exec('ng-stats');
simpleNail.stdout.pipe(process.stdout);
simpleNail.stderr.pipe(process.stderr);
simpleNail.on('exit', (code) => {
  if (code !== 0) {
    console.error(`ng-stats exited with code ${code}`);
  }
});

// Executing a custom Java class with arguments and explicit server options
const options = {
  address: 'localhost',
  port: 2113
};
const args = ['hello', 'world'];

const customNail = nailgunClient.exec('com.example.MyJavaClass', args, options);

customNail.stdout.pipe(process.stdout); // Pipe Java's stdout to Node's stdout
customNail.stderr.pipe(process.stderr); // Pipe Java's stderr to Node's stderr

// Optionally pipe Node's stdin to Java's stdin if the Java program expects input
// process.stdin.pipe(customNail.stdin);

customNail.on('exit', (code) => {
  console.log(`Java program exited with code ${code}`);
  // process.exit(code); // Uncomment to exit Node.js with the Java program's exit code
});

view raw JSON →