Whitespaces in path prevent startup of openHAB
spacemanspiff2007 opened this issue · 8 comments
To reproduce (on windows):
Download new windows snapshot of openHAB.
Extract into folder with whitespace (here 4.0 Snapshot_1
)
Navigate into folder and doubleclick start.bat
.
Observe a crash of openHAB crashes with the following error message:
Launching the openHAB runtime...
Fehler: Hauptklasse Snapshot_1 konnte nicht gefunden oder geladen werden
Ursache: java.lang.ClassNotFoundException: Snapshot_1
Replace whitespace through underscore (here 4.0_Snapshot_1
) and observe successful start.
I recently read the documentation about installation of openHAB for Windows and it is mentioned to not have space inside the path.
Now, if it could be fixed, why not ;)
I think it's somewhere in the bash/cmd files the path is not properly quoted which leads to the issue.
For completeness here is the link to the docs but I think this info should be on the download page.
because it's very unexpected to not allow spaces.
@spacemanspiff2007 I could not reproduce your issue for start.bat
, but for start_debug.bat
.
Replacing "%DIRNAME%start.bat" debug %*
by call "%DIRNAME%start.bat" debug %*
solves the issue for me.
Can you confirm?
Where have you put the space? For me it's in the last folder before the start.bat (e.g. c:\Progs\OpenHAB\4.0 Snapshot_1
).
I'll double check if call
will change anything and report back.
This is strange. I cannot reproduce anymore.
I tried the 3.4.4 release, 4.0M2, and current snapshot.
Typically, I extracted to directly to "c:\oh 4" or similar, but also tried to extract directly in the download folder.
Both start.bat and start_debug.bat now work for me, even without the proposed "fix" above.
I tried to start from explorer window, and from cmd.exe prompt.
Windows 11 Home, 22H2.
How did you start the batch files?
I tried it with a double click in the containing folder, from a cmd shell inside the containing folder and through a python script that creates a new process which has the working dir set accordingly.
I looked at setenv.bat because it does not quote the file paths when setting them as JAVA_OPTS. However when I quote them I get another error in karaf.bat which I can't resolve:
"Snapshot_1" -Dopenhab.conf="C:\Progs\openHAB\Installations\4.0" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
So I am not sure if this is the right approach at all.
The really strange thing is that I cannot reproduce - even on an older win10 version - neither with Java11 nor Java17. It just works out of the box.
Which Java distribution are you using and is it installed to the default install location?
What I have read about escaping, using setlocal enabledelayedexpansion
without any further modification could be an approach; or alternatively quoting the set calls like set "DIR=strange directory name"
and quoting every use of "%DIR%"
.
I cannot help unless I manage to reproduce the problem.
I am using Corretto and the JAVA_HOME
is set accordingly:
openjdk version "17.0.6" 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)
So you think this is a java issue and not a variable expansion issue?
I cannot help unless I manage to reproduce the problem.
Of course
What I have read about escaping, using
setlocal enabledelayedexpansion
without any further modification could be an approach;
That didn't work
quoting the set calls like
set "DIR=strange directory name"
and quoting every use of"%DIR%"
.
I tried that (see post above) but then I get a different error and I don't know the commands the fix the next issue.