npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-red-contrib-jar-func

v0.0.4

Published

a function node that calls an executable .jar file.

Readme

node-red-contrib-jar-func

Node-RED node to run executable-jar file

Using the node, Node-RED users can run any JVM based code, such as Java, Kotlin, Scala programs.

How to setup the Java environment

(1) Download and install Java Development Kit

http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

(2) Set environment variables, JAVA_HOME and PATH to enable java and javac command

http://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux

How to interact with the jar program

While this node is created, it will start running the specified jar program using the following command: java -jar {jar-file-name} The jar program can keep running without exiting. Any message arriving at the input of this node will be transmitted to the stdin of the jar program with JSON fromat, one line at a time. Each line of messages printed by the jar program's stdout will be tried to parse as JSON, if success, it will appear at the output of this node.

Example Hello.java


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Hello {

	public static void main(String[] args) {
		@SuppressWarnings("WeakerAccess")
		class Result {
			public String topic;
			public String payload;
		}

		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		//noinspection InfiniteLoopStatement
		for (;;) {
			try {
				String line = stdin.readLine();
				JSONObject obj = JSON.parseObject(line);
				String payload = obj.get("payload").toString();

				Result result = new Result();
				result.topic = "Log";
				result.payload = "输入的payload=" + payload;	// this line contains Chinese characters.

				System.out.print("it works");	// the output will be parsed line by line,
				Thread.sleep(200);		// no matter timing.
				System.out.println(" fine!");	// this will be shown on node-red console but not to output
												// because it it not a valid JSON string.

				System.out.println(JSON.toJSONString(result,
						// with unicode, Chinese characters can be displayed correctly.
						SerializerFeature.BrowserCompatible		// BrowserCompatible ==> unicode encoding.
				));	// this message will appear at the output of this node.

				System.out.println("This is a Java program.");	// only to node-red console
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

}