Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 94d2616

Browse files
committed
Finished initial bootstrap launcher functionality.
1 parent 4b33aad commit 94d2616

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

bootstrap/src/main/scala/Bootstrap.scala

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,49 @@ object Bootstrap {
88

99
val currentFolderPath: String = Paths.get("").toAbsolutePath.toString
1010
val javaHomePath: String = System.getProperty("java.home")
11+
val chatOverflowMainClass = "org.codeoverflow.chatoverflow.Launcher"
1112

1213
def main(args: Array[String]): Unit = {
1314

1415
if (testValidity()) {
1516
if (checkLibraries(args)) {
16-
// TODO: Create java path and classpath, just print for now (testing purposes)
17+
val javaPath = createJavaPath()
18+
if (javaPath.isDefined) {
19+
20+
// Start chat overflow!
21+
val process = new java.lang.ProcessBuilder(javaPath.get, "-cp", "bin/*:lib/*", chatOverflowMainClass)
22+
.inheritIO().start()
23+
24+
val exitCode = process.waitFor()
25+
println(s"ChatOverflow stopped with code: $exitCode")
26+
}
1727
}
1828
}
1929
}
2030

31+
def createJavaPath(): Option[String] = {
32+
33+
// Check validity of java.home path first
34+
if (!new File(javaHomePath).exists()) {
35+
None
36+
} else {
37+
38+
// Check for windows and unix java versions
39+
// TODO: How to handle JDK versions? Only JRE supported?
40+
val javaExePath = s"$javaHomePath/bin/java.exe"
41+
val javaPath = s"$javaHomePath/bin/java"
42+
43+
if (new File(javaExePath).exists()) {
44+
Some(javaExePath)
45+
} else if (new File(javaPath).exists()) {
46+
Some(javaPath)
47+
} else {
48+
None
49+
}
50+
}
51+
52+
}
53+
2154
def checkLibraries(args: Array[String]): Boolean = {
2255

2356
val libFolder = new File(s"$currentFolderPath/lib")
@@ -34,6 +67,7 @@ object Bootstrap {
3467
}
3568

3669
// Download all libraries
70+
// TODO: Check validity if everything is downloaded
3771
downloadLibraries()
3872

3973
} else {

0 commit comments

Comments
 (0)