How to create a portable version of VS Code + Z Open Editor (Java runtime problem) #381
Replies: 2 comments
-
PS: I found a workaround by creating a launch file (.bat or .cmd) that declares the
This work also for other extensions needing a Java runtime. It is then imperative to start the potable installation of VS Code with the created command file. |
Beta Was this translation helpful? Give feedback.
-
@FALLAI-Denis thanks for the detailed (and as always) correct analysis. We currently find Java based on the user setting, the JAVA_HOME variable, if Java is in the PATH, plus we even look in the most common installation locations for Windows and Mac. The fact that the command starting the language server does not resolve environment variables is something we can look into improving. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I need to create a portable version of VS Code, for a Windows context, that includes all necessary extensions, including IBM Z Open Editor.
This portable version must be completely autonomous. This implies that third-party components are also embedded in the portable installation.
I created an execution context with the "zip" version of VS Code for Windows: https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-archive
The deployment architecture of this archive is documented here: https://code.visualstudio.com/docs/editor/portable
I installed the various extensions which were placed in the
data\extensions
subfolder.User context and preferences are placed in the
data\user-data
subfolder.IBM Z Open Editor requires a Java runtime that is not necessarily available (or not at the correct version) on the host machine.
So I want to embed a JDK (or JRE) in the portable installation.
I copied a JDK into a
data\JAVA
subfolder:This is the IBM Semeru Java version.
On current test machine, the default Java runtime is the Microsoft OpenJDK:
But I have to give the path to this JAVA runtime using the user
settings.json
, using thezopeneditor.JAVA_HOME
parameter.In settings.json files it is not possible to refer to environment variables: the
{$env:ENVAR}
syntax is not supported.You must use one of the VS Code predefined variables: https://code.visualstudio.com/docs/editor/variables-reference#_predefined-variables
The only available variable that refers to the VS Code installation context is
${execPath}
.However, this variable references the VS Code executable itself, and not only the folder containing this executable.
To return to the path you must use the expression
${execPath}\..\
.This syntax works well for referencing files.
It also works with ZOE to detect the JAVA version used, but not to run the Language Server necessary for ZOE:
In User
settings.json
:"zopeneditor.JAVA_HOME": "${execPath}\\..\\data\\JAVA"
In output for extension:
According ZOE log, JavaFinder find the IBM Semeru version for portable installation.
When opening a COBOL file:
The expression
${execPath}\..\data\JAVA\bin\java.exe
should be resolved inX:\installation_folder\Code.exe\..\data\JAVA\bin\java.exe
, what doesn't work...However, in a "Windows Terminal" the syntax is accepted:
In conclusion, my analysis is that JavaFinder manages to execute the JDK indicated in the
zopeneditor.JAVA_HOME
parameter of Usersettings.json
, but ZOE cannot execute it...If the JavaFinder module used is the one available here, https://github.com/HanSolo/javafinder, we see that it resolves the access path:
https://github.com/HanSolo/javafinder/blob/709f5825863518b0ffbe24c70de205edd0900d40/src/main/java/eu/hansolo/javafinder/Finder.java#L114
See: https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html#get-java.lang.String-java.lang.String...-
Would it be possible for ZOE to do the same Java executable path resolution as JavaFinder?
Failing that, do you know of a method to declare an access path relative to the
zopeneditor.JAVA_HOME
parameter?Note: same problem with IBM Db2 for z/OS Developer extension, probably same reason.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions