- Back to Home »
- Java »
- [Java] GUI Application (Swing on Eclipse)
Wednesday, May 5, 2021
1. Install Eclipse for java
Download and install "Eclipse IDE for Java Developers"
2. Create new project
- Open Eclipse
- File > New > Java Project
- Fill project name
- Click Finish button
- New package
Right click on src > New > Package
- New Application Window (Swing JFrame)
Right click on package mycompany > New > Other
> select Application Window > Next
> input Name of application window > Finish
- Drag and drop companent to window
Can switch Source <=> Design
Note:
If Design mode do not display, right click on java source file and select
Open With > WindowBuilder Editor
3. Add external library
- Create new folder and put jar into there
Right click on project > Properties > Java Build Path > Libraries > Add JARs...
> select jar files > OK
External jar files was added to Referenced Libraries
4. Export to Runnable JAR file
Right click on project > Export > Java - Runnable JAR file > Next
> select "Launch configuration", input "Export destination" > Finish
JAR file will be exported to Export destination folder, double click to run jar file.
(All external libararies and other project's resource also put in to Hello.jar export file)
Note: Can use command promt with command below
$ java - jar Hello.jar