Getting started with openHAB 2 and Eclipse IDE

Hi everyone! I’m trying to get started in this world of openHAB 2. I want to develop some addons for it but I’m really confused about how all this works. I have experience working with Java and the Eclipse IDE. I followed the steps described here to set-up the IDE. Everything works, I got it running and displaying the messages on the console output.

Now, I’m asking myself, where’s the Java code? I only see configuration files but not a single source code file. Where’s the code that is producing the output I see in the console? Here’s my Eclipse project tree:

Also on localhost:8080 I don’t have any UI. Do I have to clone the openhabs2-addons repo to get a UI? How do I add this addons to openhab to be able to debug them, either the already created ones or the addons I create.

Thank you very much for your help! I’ve spent hours reading through the docs and forums trying to clarify this. It’s probably a really simple question, hope you can help me!

1 Like

Hi Andrés,

it seems that you did not select the repositories as descriped in step 4 of the installation description. Your selection in the Eclipse Installer should look like this:

And the project structure in Eclipse will be the following after installation and first start of eclipse (it may take some time until all projects appear in Eclipse):

1 Like

Hoooo I must missed that one! I only selected one of them when I double clicked it. Thank you very much, will try it when I get home.

I still have the doubt, how did the code run? Is the code in some of the jar files in the imported plug-ins?

Ok, I installed eclipse from the start once more, this time selection everything as you marked, this are the projects in Eclipse now:

The problem is, I’m getting tons of errors! 235 errors and 3501 warnings!! My Java version is 1.8.0_121 64-bit. This are part of the errors:

As an example, the first error is import errors:

I did the Help > Perform Setup Tasks and cleaned all the projects but still the same errors. I’m on Windows 10 64-bit also if that helps. I installed maven too. In the installer I selected this options:

Am I missing anything? I noticed that if I follow this steps:

Open the “Infrastructure > launch” folder. Right click on openHAB_Runtime.launch, select “Run as > openHAB_Runtime”. You should now begin to see output in the console window.

openHAB is launched and I see the output on the console even with all the errors! I still can’t see anything on localhost:8080 just a Access Error: 404 -- Not Found

I just tried it on my machine (Windows 10, 64 Bit Java 8). After the start of Eclipse I have also lots of errors (249). But that’s not a real problem, because most of the errors are located in test classes or OH 1 bindings. To get rid of the errors I normally close these projects.

I did not run Help/Setup Task. I simply started the runtime and was able to connect without any problems. I would try to cleanup everything, perform a new install (without Setup Task) and try it again.

I still have the doubt, how did the code run? Is the code in some of the jar files in the imported plug-ins?

If you open the run configuration and select page “Plug-Ins” you can see where the executable code comes from. Some is exexecuted from your workspage but most is loaded from the target platform.

I see, so maybe something with my computer. I get a when accessing localhost:8080 I get a Access Error: 404 -- Not Found when running openHAB and just a page not found error when not running it so openHAB is doing something there, maybe a problem with that port on my PC.

Can I change that port? I read that I should edit the start.bat file to change the port but I see configurations done on that script. I also couldn’t find any config file to change the port.

Thank you very much for your help and patience with me Martin! :slight_smile:

EDIT:

Yess! Got it working on 8080! I wen through the logs and saw an error binding to the 8080 port. I discovered an installed app was using that port. Really thank you for your help! If you don’t mind, I would still like to know how to change the port.

Thank you so much Martin!!

I found it: you can change the port on the Arguments page in the launch configuration. There are several VM arguments and you only need to change the port in -Dorg.osgi.service.http.port=8080 to a different port.

Thank you so much Martin!!

You are welcome.