Skip to content

Detect openjdks #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified head/head.o
Binary file not shown.
33 changes: 30 additions & 3 deletions head_src/head.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,13 @@ int findNextVersionPart(const char* startAt)

char* firstSeparatorA = strchr(startAt, '.');
char* firstSeparatorB = strchr(startAt, '_');
char* firstSeparatorC = strchr(startAt, 'u');
char* firstSeparator;
if (firstSeparatorA == NULL)
if (firstSeparatorC != NULL)
{
firstSeparator = firstSeparatorC;
}
else if (firstSeparatorA == NULL)
{
firstSeparator = firstSeparatorB;
}
Expand Down Expand Up @@ -490,9 +495,23 @@ BOOL isJavaHomeValid(const char* keyName, const int searchType)
BOOL valid = FALSE;
HKEY hKey;
char path[_MAX_PATH] = {0};

char searchKeyName[_MAX_PATH] = {0};
char searchValueName[_MAX_PATH] = {0};
if(strstr(keyName, "AdoptOpenJDK") != NULL)
{
strcpy(searchValueName, "Path");
strcpy(searchKeyName, keyName);
appendPath(searchKeyName, "hotspot\\MSI");
}
else
{
strcpy(searchValueName, "JavaHome");
strcpy(searchKeyName, keyName);
}

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
keyName,
searchKeyName,
0,
KEY_READ | (searchType & KEY_WOW64_64KEY),
&hKey) == ERROR_SUCCESS)
Expand All @@ -501,7 +520,7 @@ BOOL isJavaHomeValid(const char* keyName, const int searchType)
unsigned long bufferlength = _MAX_PATH;
unsigned long datatype;

if (RegQueryValueEx(hKey, "JavaHome", NULL, &datatype, buffer,
if (RegQueryValueEx(hKey, searchValueName, NULL, &datatype, buffer,
&bufferlength) == ERROR_SUCCESS)
{
int i = 0;
Expand Down Expand Up @@ -655,6 +674,14 @@ BOOL findJavaHome(char* path, const int jdkPreference)
jdkPreference);
}

// AdoptOpenJDK
if (search.foundJava == NO_JAVA_FOUND)
{
regSearchJreSdk("SOFTWARE\\AdoptOpenJDK\\JRE",
"SOFTWARE\\AdoptOpenJDK\\JDK",
jdkPreference);
}

if (search.foundJava != NO_JAVA_FOUND)
{
strcpy(path, search.foundJavaHome);
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/launch4j/config/Jre.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Jre implements IValidatable {
public static final String ARGS = "jvmArgs";

// __________________________________________________________________________________
public static final String VERSION_PATTERN = "(1\\.\\d\\.\\d(_\\d{1,3})?)|[1-9][0-9]{0,2}(\\.\\d{1,3}){0,2}";
public static final String VERSION_PATTERN = "(1\\.\\d\\.\\d((_|\\.)\\d{1,3})?)|[1-9][0-9]{0,2}(\\.\\d{1,3}){0,2}";

public static final String JDK_PREFERENCE_JRE_ONLY = "jreOnly";
public static final String JDK_PREFERENCE_PREFER_JRE = "preferJre";
Expand Down