How to: Install and setup requirements for openHAB development under Windows

Since I have just needed to reinstall my windows based PC, I thought I would document the steps needed to setup a working dev setup to make it quicker for myself and anyone else that needs to. The openHAB documentation is found at this link, but it does not cover the how to install or test all the software needed.

Setup the Development Environment for openHAB

Downloads needed:

Maven – Download Apache Maven

Git - Downloading Package (git-scm.com)

Java Downloads | Oracle

Eclipse Installer 2023-03 R | Eclipse Packages

Setup Enviroment Variables

Whilst downloading the above files, you can open a command prompt and enter in these lines, adjusting the paths to the correct ones (note the version you’re downloading for maven):

set PATH="c:\program files\apache-maven-3.9.2\bin";%PATH%

set JAVA="c:\program files\Java\jdk-17\bin"

set PATH="c:\program files\git\bin";%PATH%

Installing the three requirements requires you to unzip the contents manually to the folder locations in the above commands, and to set the variables with the above commands. The Java JDK does have a zip, exe or msi installer options to choose from, all will work but the enviroment variables need to be set.

After installing it is a good idea to test. To do this, you need to close the command prompt window and reopen a new one for the new environment variables to be recognized. Now you can type in java , mvn and git and these commands should work without needing to be inside the correct folders. If they do not work, you will need to fault find why before moving on.

You can view and edit the path and java environment variables by simply typing in ‘environment variables’ into the start bar search and selecting the result. In the System Properties window that appears, there is a button called ‘environment variables’ down the bottom.

Setting up Eclipse

This is straight forward if you follow the openHAB docs in the first link above. Should you get any errors it may be because of write permissions to the c:\program files\ folder and changing the default install location to be c:\eclipse\ will resolve this.

Setting up EGit

After Eclipse is running, go to the HELP menu and select “Eclipse Marketplace”. Use the search to find “EGit” and it may already be installed, if not press the install button.

Navigate the menu as follows:

WINDOW>SHOW VIEW>OTHER>
Expand the GIT tree and select one at a time:

  1. Git repositories
  2. Git Staging.

Now you can use GIT inside the IDE to do the most common tasks in a graphical way without needing to know the command line version. To do some things with git, the command line is still going to be needed, but this can speed up your workflow IMHO. You can view the difference between files yet to be committed, undo single lines or all changes and edit directly in Eclipse.

Signing Commits

Still to document:

GIT token setup

On the windows command line enter:

winget install --id GitHub.cli

This downloads and installs the github CLI and is needed to store your Personal Token. Answer Y to agree to the Legal stuff.
Close the command prompt window and open a new one as the above added itself to the PATHS.

Now enter in

gh auth login

Select the following options:

GItHub.com
HTTPS
Yes
Login with web browser

Copy the code across to the web browser and this will store the auth so you can use git without using a token every time.

4 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.