From 95654451f10b41c70ab2837af7c24a4043469408 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Oct 2024 08:33:29 +0100 Subject: [PATCH] Added jar app asset support to snap --- how-to/workspace-platform-starter/CHANGELOG.md | 18 ++++++++++++++++++ .../client/src/framework/snap.ts | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/how-to/workspace-platform-starter/CHANGELOG.md b/how-to/workspace-platform-starter/CHANGELOG.md index 8843cc31b..535d6e076 100644 --- a/how-to/workspace-platform-starter/CHANGELOG.md +++ b/how-to/workspace-platform-starter/CHANGELOG.md @@ -38,6 +38,24 @@ - Updated the example content creation rule to support specifying a default view placement position when window.open is called from inside a view. Defaulted it to "stack-right" so that it has the same behavior as Chrome/Edge when window.open is called without a target (opens a new tab to the right hand side of the tab). It is now turned on by default in the main manifest (search for view-position-content-creation)Turned it on by default (the example app content Content Creation Examples will now work). See [How to Customize Content Creation Rules](./docs/how-to-customize-content-creation-rules.md). - Change - Updated the platform mapper (configurable option to make snapshots smaller when sending to custom endpoints) so that it no longer strips out snapshotDetails as we received feedback that it resulted in monitor placement not working as it should. - Enhancement - Added support for SNAP SDK 1.0.0 +- Experimental - Added support for launching a jar app asset through snap. JAVA_HOME needs to be defined as an environment variable with the following new snap 1.0.0 combined strategy: + +```json +"launchPreference": { + "options": { + "type": "native", + "snap": { + "strategy": { + "type": "combined", + "timeoutMs": 60000, + "matchNameRegex": "^Java Starter*", + "multiProcess": true, + "expectedWindowCount": 50 + } + } + } + } +``` ## v19.0.0 diff --git a/how-to/workspace-platform-starter/client/src/framework/snap.ts b/how-to/workspace-platform-starter/client/src/framework/snap.ts index 580e81885..cc898d7c7 100644 --- a/how-to/workspace-platform-starter/client/src/framework/snap.ts +++ b/how-to/workspace-platform-starter/client/src/framework/snap.ts @@ -297,6 +297,21 @@ export async function launchApp( ): Promise { try { if (server) { + if (path.endsWith(".jar") && !path.includes("java.exe") && !path.includes("javaw.exe")) { + logger.info("Launching a jar file, checking JAVA_HOME environment variable"); + const javaHome = await fin.System.getEnvironmentVariable("JAVA_HOME"); + if (!isEmpty(javaHome)) { + const javawExe = `${javaHome}\\bin\\javaw.exe`; + args?.unshift(path); + args?.unshift("-jar"); + path = javawExe; + logger.info(`Using ${javawExe} to launch the jar file and moved the original path to the args`); + } else { + logger.warn( + "JAVA_HOME environment variable is not set, unable to update the path. Passing as is to snap to try to resolve." + ); + } + } const clientId = `${NATIVE_APP_PREFIX}/${appId}/${instanceId}`; let launch = true;