package options

import (
	"os"
	"path/filepath"
	"strings"
)

var (
	VerboseClass    bool
	ThreadStackSize uint
	AbsJavaHome     string // /path/to/jre
	AbsJreLib       string // /path/to/jre/lib
)

func InitOptions(verboseClass bool, xss int, useJavaHome bool) {
	VerboseClass = verboseClass
	ThreadStackSize = uint(xss)
	initJavaHome(useJavaHome)
}

func initJavaHome(useOsEnv bool) {
	jh := "./jre"
	if useOsEnv {
		jh = os.Getenv("JAVA_HOME")
		if jh == "" {
			panic("$JAVA_HOME not set!")
		}
	}

	if absJh, err := filepath.Abs(jh); err == nil {
		if strings.Contains(absJh, "jre") {
			AbsJavaHome = absJh
			AbsJreLib = filepath.Join(absJh, "lib")
		} else {
			AbsJavaHome = filepath.Join(absJh, "jre")
			AbsJreLib = filepath.Join(absJh, "jre", "lib")
		}
	} else {
		panic(err)
	}
}

package options

import (
	"os"
	"path/filepath"
)

var (
	VerboseClass    bool
	ThreadStackSize uint
	AbsJavaHome     string // /path/to/jre
	AbsJreLib       string // /path/to/jre/lib
)

func InitOptions(verboseClass bool, xss int, useJavaHome bool) {
	VerboseClass = verboseClass
	ThreadStackSize = uint(xss)
	initJavaHome(useJavaHome)
}

func initJavaHome(useOsEnv bool) {
	jh := "./jre"
	if useOsEnv {
		jh = os.Getenv("JAVA_HOME")
		if jh == "" {
			panic("$JAVA_HOME not set!")
		}
	}

	if absJh, err := filepath.Abs(jh); err == nil {
		AbsJavaHome = absJh
		AbsJreLib = filepath.Join(absJh, "lib")
	} else {
		panic(err)
	}
}

--- 
+++ 
@@ -3,6 +3,7 @@
 import (
 	"os"
 	"path/filepath"
+	"strings"
 )
 
 var (
@@ -28,8 +29,13 @@
 	}
 
 	if absJh, err := filepath.Abs(jh); err == nil {
-		AbsJavaHome = absJh
-		AbsJreLib = filepath.Join(absJh, "lib")
+		if strings.Contains(absJh, "jre") {
+			AbsJavaHome = absJh
+			AbsJreLib = filepath.Join(absJh, "lib")
+		} else {
+			AbsJavaHome = filepath.Join(absJh, "jre")
+			AbsJreLib = filepath.Join(absJh, "jre", "lib")
+		}
 	} else {
 		panic(err)
 	}
Support both jre and jdk path for -XuseJavaHome
