JS2Jar
Compile Nashorn script to Java application
Install
- Install dependencies
- Install JS2Jar
npm install -g js2jar
Usage
Create an app
js2jar create myApp
Build and run the app
cd path/to/myAppjs2jar 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 └---mainjs //Main script file
Example
myApp|---build| |---lib| | └---mylibjar| └---media| └---mypicjpg└---src |---mainjs └---foojs
foo.js
main.js
var JFrame = Javatype"javax.swing.JFrame";var JPanel = Javatype"javax.swing.JPanel";var JButton = Javatype"javax.swing.JButton";var JLabel = Javatype"javax.swing.JLabel";var ImageIcon = Javatype"javax.swing.ImageIcon";var MyLib = Javatype"com.mylib.MyClass"; var win = "My Window";win;win; var panel = ;win; var picLabel = "media/mypic.jpg";panel; win;