Get Started
Here is a step-by-step instruction to start making your application using swing-ui module. If you find issues with these steps or instructions, please report to me as soon as possible.
Requirements
- Windows, Linux, or Mac as operating system
- Node.js 18+
- npm (Node package manager) installed
- Java 11 JDK or higher to run the main .jar file that’s inside of swing-ui module
Once you have the necessary Node.js and Java installed, make sure that their executables’ directories are added to system’s PATH list. It should be done in Windows as well as linux. You can check if it’s done by command:
java -version //to test java installation
node -v // to test Node.js installation
If they both show their version numbers, then you don’t have to add their directory to PATH. If any of them doesn’t work because system says that command is not found or something like that, then:
- Their executables directory have to be added to system PATH list, or just add Node.js executable to PATH list and …
- You can use full path to your Java executable to run gui.jar file inside of swing-ui module. This allows to run gui.jar with a different Java version than your default one in situations when you have multiple version of Java installed.
I will show example of each situation below.
Installation
- Create a directory of your new project
- Navigate to that directory with your preferred terminal, such as
cmd.exe
on Windows or bash on Linux. - Run this command to set up Node.js project
npm init // sets up a new project
4. Run this command to install swing-ui module
npm install swing-ui
5. Run the following command to execute gui.jar, which will create the main JavaScript file with demo application to get your started.
java -jar poject_path/node_modules/swing-ui/gui.jar
// ... or if you want to specify full path to java, you can do it like this on Windows:
"C:\Program Files\Java\jdk-11.0.22\bin\java.exe" -jar node_modules/swing-ui/gui.jar
// replace the path to java with your java installation path
// To run it without console window on Windows use:
start javaw -jar poject_path/node_modules/swing-ui/gui.jar
// in this example you can also use full path to javaw.exe as shown in example above
If all went well, your should have a working demo application up and running. Congratulations!
To make it easier to run this command each time to launch your application you should make a batch file with this command, such as MyApplication.bat
on Windows or MyApplication.sh
on Linux. Just make sure to set executable permission to this file on Linux to be able to execute. It can be done with this command:
chmod +x MyApplication.sh
Now What?
Now you are ready to explore the JavaScript API to the Java Swing library components within gui.jar file you are executing. Check out documentation to use main gui
object and its functions, and then each UI component as a building block of your awesome application. And of course, most of all have fun building it.