1.0.6 • Published 7 years ago

js2jar v1.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

JS2Jar

Compile Nashorn script to Java application

Install

  1. Install dependencies
  1. Install JS2Jar
npm install -g js2jar

Usage

Create an app

js2jar create myApp

Build and run the app

cd path/to/myApp
js2jar build

or

js2jar build path/to/myApp

It will build the application in the build directory

Project structure

myApp
|---build
|   |---lib        //.jar libraries
|   └---media      //Media files like images, sounds, videos
└---src
    └---main.js    //Main script file

Example

myApp
|---build
|   |---lib
|   |   └---mylib.jar
|   └---media
|       └---mypic.jpg
└---src
    |---main.js
    └---foo.js

foo.js

print("Hello! I am foo.js")

main.js

load("foo.js")
var JFrame = Java.type("javax.swing.JFrame");
var JPanel = Java.type("javax.swing.JPanel");
var JButton = Java.type("javax.swing.JButton");
var JLabel = Java.type("javax.swing.JLabel");
var ImageIcon = Java.type("javax.swing.ImageIcon");
var MyLib = Java.type("com.mylib.MyClass");

var win = new JFrame("My Window");
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setSize(400, 400);

var panel = new JPanel();
win.add(panel);

var picLabel = new JLabel(new ImageIcon("media/mypic.jpg"));
panel.add(picLabel);

win.setVisible(true);

See more about Nashorn

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago