If it is not explicitly told in following recipe, setting up services are described for Ubuntu 20.04 server, but applications are described for Xubuntu 20.04 workstation. If you use different Ubuntu version or Linux distribution, settings as well as content, names and places of configuration files may be different!
Got it.

16. GUI Application

Main steps

Implement color slider GUI application

  1. Install WindowBuilder plugin for eclipse.
  2. Investigate jtm.activity16 package
  3. Implement class ColorSlider to make color sliders changing test area background color

Export application in executable *.jar file

  1. Export ColorSlider class as executable jar file. In Eclipse, do following:
    1. Right click on ColoSlider.java file in Package explorer, and select Export...
    2. Select Java — Runnable JAR file, and press Next,
    3. In Launch configuration select ColorSlider - Aaaaaa (where Aaaaaa is your project),
    4. In Export destination enter Aaaaaa/src/main/java/jtm/activity16/color-slider.jar (where Aaaaaa is your project)
    5. In Library handling select Package required libraries into generated JAR
    6. Press Finish,
    7. If errors/warnings are reported, press OK (you may ignore warnings, but have to fix errors).
  2. Open terminal and check, execution of jar file from command line:

    cd ~/Aaaaaa/src/main/java/jtm/activity16/
    java -jar color-slider.jar 
  3. Check that tests in ColorSliderTestSuite test suite are passing.

Make jar file smaller

When done as simple export in Eclipse, jar file contains all libraries listed as project dependencies included, which are not necessary just for Swing application. You can make *.jar file much smaller by including only required libraries.

  1. Install ant building system:

    sudo apt install ant
  2. Right click on ColoSlider.java file in Package explorer, and select Export...
  3. Select Java — Runnable JAR file, and press Next,
    1. In Export destination enter Aaaaaa/src/main/java/jtm/activity16/color-slider.jar (where Aaaaaa is your project)
    2. In Library handling select Package required libraries into generated JAR
    3. Also select Save as ANT script and set some location of it (e.g. export.xml in your project) and finish export.
  4. Open export.xml file and delete all zipfileset dir="... like entries, except:

    <zipfileset dir="/home/student/.m2/repository/com/miglayout/miglayout/3.5.5" includes="miglayout-3.5.5.jar"/>

    Do not delete <fileset dir="${dir.buildfile}/target/classes"/> entry, which is easy to lose between zipfileset dir="... entries!

  5. Right click on export.xml and select Run as — Ant build.
  6. Check that now color-slider.jar is few hundred kilobytes in size.

You can use design of ColorSliderTest.java class as a template for GUI test for your teamwork project.

More info


  

Created by Valdis Vītoliņš on 2021-01-27 15:09
Last modified by Valdis Vītoliņš on 2024-08-27 17:28
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License