From 70a77a20db0ee4d25b2023c4409dc50c6f737f2a Mon Sep 17 00:00:00 2001 From: theapache64 Date: Sun, 9 Jan 2022 00:16:19 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20add=20possible=20fix=20for=20#82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stackzy/ui/feature/splash/SplashViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashViewModel.kt b/src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashViewModel.kt index 4b34e43..2596d2c 100644 --- a/src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashViewModel.kt +++ b/src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashViewModel.kt @@ -66,10 +66,11 @@ class SplashViewModel @Inject constructor( } private fun checkJdk(onExist: () -> Unit) { - val isJdkExists = System.getenv("JAVA_HOME") != null - if (isJdkExists) { + try { + Runtime.getRuntime().exec("java -version"); + // jdk exists, pass callback onExist() - } else { + } catch (e: IOException) { _syncFailedMsg.value = "Ohh no! It looks like you don't have JDK installed 😥" } }