Inside your Java application with the browser

yolpos
3 min readJun 3, 2018

--

An Http API for your Java Program

nudge4j adds a tiny http API to any Java program so that you can do this:

or this:

or this:

That is:

“you can throw any code to your JVM and see what happens”.

And by the way, the last example is also interesting as it shows that you could run a snippet of code which could be anywhere on the internet.

Technical Note: 
In nudge4j, all API access is over HTTP, and accessed from http://localhost:port/js
All data is returned as 'text/plain' with 'charset=UTF-8'
Both GET and POST are supported.
All requests must specify the parameter '?code='

Start with the Browser

The HTTP API makes it easy to build a Web App (a few static HTML pages) on top of it. So, let’s park curl for a moment and let me show you what you get if you go to http://localhost:5050/ with your browser.

At the time my writing (June 2018) we have a :

index.html

This is the landing page. It provides a small dashboard telling you things like

  • the JVM process you are connected to
  • the JVM uptime
  • where the code that launches nudge4j was wired up
  • (last but not least) links to all other pages

remote.console.html

The remote console is where you write your code to execute against your JVM. You have a cool editor with syntax highlighting and the execute button. And the whole stack trace in the browser if what you send to the JVM makes it go belly-up.

execution.history.html

The execution history is where you find your previously executed scripts. You know: it takes time to craft a good script and scripts might be very specific to just your Java application. Losing them is frustrating, but it’s hard to know where to save it. So any snippet you try is stored on the browser’s local storage. A fair compromise.

examples.html

Simple and generic examples for you to try.

Non-intrusive integration with nudge4j

So now, Did you get intrigued ? Fancy giving nudge4j a try now ? Had I followed any marketing tip I guess I should have told you this at the beginning:

Just copy/paste the code below in your Java program and you ready to go

--

--