Bypassing Java on jpexs-decompiler

I wish I can crack or bypass passwords set on Winrar like Yoyodiy, but I just can't.

Okay, enough Smalltalk, let's talk about how to run JPEXS Decompiler if your Java implementation is OpenJDK instead of the Java Development Kit(JDK).

The problem

I install OpenJDK as my computer's Java implementation. However, JPEXS Decompiler said I don't have Java which deeply puzzled me.

Monitoring

To understand why it had happened, I need to watch actions during the bug occurred.

Firstly the message box said "This application requires a Java Runtime Environment 1.8.0", then the application opens a website: https://java.com/en/download.

Luckily jpexs-decompiler opens its source to Github to find what happened with source code.

Troubleshooting: Searching

After downloading the whole project, I firstly search the text "This application requires a Java Runtime Environment 1.8.0" to find out which variables use this text, but the string doesn't exist.

Strange, but there's always a way: I later try to search the text "java.com/en", and bingo, nsis_plugins/JREDyna_Inetc.nsh use this text. Therefore, I try to research which functions call this text.

A function in nsis_plugins/JREDyna_Inetc.nsh make me interested during searching: Function DetectJRE.

I guess the function have something I need to know.

Troubleshooting: Registry Windows

Interesting codes are around line 300:

;DetectJRE64:
  SetRegView 64
  ; first, check for an installed JRE
  ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
  StrCmp $1 "" DetectJDK64
  ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$1" "JavaHome"
  StrCmp $2 "" DetectJDK64
  Goto GetJRE

; bypass
  
  IfFileExists "$2\bin\java.exe" 0 NoFound

What is ReadRegStr here? The manual said it reads strings on Registry program.

HKLM here means HKEY_LOCAL_MACHINE, so it means the function reads keys on HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment. There are two keys in the function need to check: CurrentVersion and ''version''\JavaHome.

"How about making a route to my OpenJDK?" I think, then I add my OpenJDK path to ''version''\JavaHome.

It is a success. But how?

How to do it

Firstly open the registry editor.

Then open the HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment key. Generally, most people install Java from Oracle which includes the JDK, and JDK will generate registry key here; But we are using OpenJDK, and the HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment key doesn't exist. We need to add a new string and specify our path.