I don’t run on Windows and never have so I can’t say the bat file makes much sense to me either. But I know there are hundreds if not thousands of users who run OH on Windows so there being something fundamentally wrong with the .bat file seems unlikely or all those users would be complaining also.
So, assuming that there is nothing wrong with the .bat file the usual suspects for problems are:
- wrong version of Java
- environment variables like JAVA_HOME and PATH are not set up correctly
- Something already using the network ports OH needs
- Windows firewall is blocking access to the OH ports.
I can say for a fact that the -D are definitely arguments to Java. One uses the -D option to pass environment variables to the running application. In this case the two you point out are setting a couple of environment variables in the program to set the HTTP and HTTPS ports that OH will listen on. The %HTTP_PORT% is referring to a variable set by the .bat file, or that exists in your envrionment. If those variable do not exist then the defaults of 8080 and 8443 are used.
I just went through the steps on my Windows machine:
- My system already has Oracle Java 8 installed
- Added JAVA_HOME to my environment variables
- Downloaded the 2.3 R Manual Distro
- Extracted the zip file to C:\openhab2
- Ran start.bat
So unless you want to learn how the .bat file works, I think your time would be better spent looking at the list above for the source of your problem.
I don’t know for sure but I would guess it sets the language and perhaps the time zone and number formats and such that OH will use. So if you are in Germany all the logs and menus are in German and a comma is used for the decimal place and such.
A quick google search confirms this: setlocal | Microsoft Learn
Everything in % % refers to a variable set somewhere. So this line is setting the variable %DIRNAME% to the value of the environment variable %~dp0%. And again, [a Google search tells me] (batch file - What does %~dp0 mean, and how does it work? - Stack Overflow)
The %~dp0 (that’s a zero) variable when referenced within a Windows batch file will expand to the drive letter and path of that batch file.
Run the command located at %DIRNAMEruntime\bin\karaf.bat and pass all the command line arguments passed to this .bat file to that command (Google again tells me that is what the "%" means). And since %DIRNAME% was set to %~dp0~ and we now know that %~dp0% is the drive letter and path to the .bat file executing we know this makes the command c:\openhab2\runtime\bin\karaf.bat
(we didn’t pass any arguments to run.bat so %* is blank.
Why would you try to run a .bat file using Java?
No, karaf.bat is a .bat file. This is Windows scripting. It has nothing to do with Java so Java can’t figure out how to run it. If you opened that file up I bet you would find java being called from that file.
Then at least hijack a thread that is a little closer to your problem. This thread is addressing getting OH running on Windows. Not many of the people on this thread will have any clue how to help you with your problem.
Or just wait the day it takes until you have permission to start a new thread, assuming that is your problem.