This cookiecutter defines a simple Hello world Java application that uses JavaFX + JavaFX FXML as the GUI library and JUnit as the unit testing library.
Before using this template you need to install:
git
: it is used to download this template from GitHubpython 3
: the template engine is written and executed in pythoncookiecutter
library for python: template engine, creates the project folder from this templateJava JDK
: needed to program Java applicationsMaven
: project management and comprehension tool. Installs dependencies and runs builds/tests from the terminal.
Steps to install the prerequisites:
NOTE: if you install something and you can't run it using the command line, try closing the terminal and then open it again.
-
Install git.
For debian based distros (like Ubuntu) use:
sudo apt install git
For Windows you can download the setup from the official website here.
-
Install python 3. Make sure it is available in PATH:
python3 --version
Also try
python --version
orpy --version
if that doesn't work. -
Install cookiecutter using PIP:
python3 -m pip install --user cookiecutter
If
python3
didn't work in the command above, use the working alternative.If the command fails, try without the
--user
flag.Try running this command to check if cookiecutter was installed correctly:
cookiecutter --version
-
Install Java JDK (Java Development Kit).
-
Install Maven.
For debian based distros (like Ubuntu) use:
sudo apt install maven
For Windows the easiest way of installing Maven is to use chocolatey.
Install chocolatey and then run the following command inside powershell:
choco install maven
You can also use a Graphical User Interface for chocolatey. But first you need to install it using this command:
choco install chocolateygui
After that you can install Maven from the chocolatey tab, search for "Maven" and install it.
Try running this command to check if Maven was installed correctly:
mvn --version
You might want to check out Scene Builder: it is an application that allows you to design your JavaFX GUI
without programming and then export the design as an .fxml
file.
You can use the exported file to use your GUI inside your Java FX application.
You will only need to program the functionality of each component to make them do something.
-
Run cookiecutter and answer the prompted questions.
Cookiecutter will ask you to enter values for these parameters:
projectName
: project nameartifactId
: it is the name of the main executable. For example, you can use the project name or something like "MainApp".groupId
: Group identifier, "inverse" URL format (the same format as the javapackage name
convention). You can choose something like "org.example.myapp".java_package_dir
: use the value suggested to you by pressing enterversion
: application versionos
: are you developing on a "linux/other" OS machine or on a "windows" machine?indent_style
: do you prefer "space"(s) or "tab"(s) as your identation style?indent_size
: indentation size
Here is the command that will prompt you these questions:
cookiecutter https://github.com/mario33881/cookiecutter-javafx_fxml_junit.git
-
Read the
README.md
file inside the project template to get started.
Change the files as you like with your favourite IDE or text editor.
You can run the application and tests by using an IDE or by running Maven from the command line.
More instructions inside the project's
README.md
file
Next time you can simply run the following command to create a new project:
cookiecutter cookiecutter-javafx_fxml_junit
Cookiecutter saves the template locally in the
.cookiecutter
folder (located inside the home folder)
2022-04-06 Version 1.0.0:
first version