Git Product home page Git Product logo

unij's Introduction

UniJ - Java to JavaScript Bridge

Connect your Java applications with the Browser, Node.js or any other platform that supports WebSockets.

Why would you do that? Well you could write a nice UI in HTML/CSS for your Java app, create a web application or just use Java and JavaScript in the same project.

Be aware: UniJ is still in an early stage of development.

How to use UniJ?

The connection is based on the concept of procedures. A procedure is a method which is available for others to execute. This means the browser can execute a procedure on the server and the other way around. Any party can do this independently.

Here a simple example where the browser creates a procedure which the Java application then executes.

~ imaBrowserScript.js

  // Make drawing trees available for others to call
  UniJ.addProcedure("drawTree", (tree) => draw(tree));

~ SeriousBusinessLogic.java

  // Execute a procedure called "drawTree" in the browser
  UniJ.execute("browser", "drawTree", new Tree());

That's it!

And yes, you can send any objects back and forth and don't have to worry about casting.

Get it!

There is a server and a client available in the releases. And soon there will be maven repository available.

FAQ

Is it possible to connect to other languages as well?

Yes, UniJ uses WebSockets and can therefore connect with any platform that supports it. However so far there only exists a JavaScript client.

How is UniJ different from a REST API?

UniJ uses WebSockets which allow for bi-directional communication, where as with regular HTTP the client always initiates communication. WebSockets allow the server to easily emit changes to the clients without the need of client side polling. Also there is a lot less overhead when using the connection for many small messages because the connection stays open.

And lastly you don't have to worry about casting and parsing of messages and their content. UniJ does it automatically.

How fast is UniJ?

Essentially as fast as WebSocket allows. UniJ does only minimal processing, namely casting, serialization and routing.

The Round-Trip-Latency of a message is ~0.18ms which will allow for more than 5k distinct messages to be send to the client and back per second (of course the values depend on the network). But there is also the possibility to add a custom WebSocket if raw byte streaming is desired.

Requirements

  • Java 8
  • Platform with WebSocket support (i.e. Browser, Node.js)

unij's People

Watchers

James Cloos avatar Benjamin Maxwell avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.