moisescastellano / javadecompiler-tcplugin

JavaDecompiler Total Commander plugin
GNU General Public License v3.0
4 stars 1 forks source link

JRE not found #1

Closed pdario closed 2 years ago

pdario commented 2 years ago

Hello! I'm trying to use Java Decompiler plugin, but i always says JRE is not installed. I have both JDK 17 and JRE 8 in my "Program Files\Java". What is missing?

moisescastellano commented 2 years ago

Ciao Dario, thanks for reporting this issue:

Short answer:

Add these 2 properties to the [JVM] section in the _[TOTALCMD-INSTALL-DIR]/wcx/JavaDecompiler/tc_javaplugin.ini_ file, changing the paths to your JRE install dir:

JVM_DLL=c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll
JVM_HOME=c:\Program Files\Java\jre1.8.0_311

Let me know if that works.

Long answer:

The Java plugin interface searchs for the JRE in two ways:

  1. In the Windows Registry, it searchs for the key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

    there it queries for "JavaHome" and "RuntimeLib", e.g. my computer registry values:

    JavaHome        C:\Program Files\Java\jre1.8.0_311
    RuntimeLib      C:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll
  2. If those values do not exist, it searches for the config file: _[PLUGIN_DIR]/tcjavaplugin.ini

    in that file, in the [JVM] section, it searches for two properties:

    JVM_DLL=c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll
    JVM_HOME=c:\Program Files\Java\jre1.8.0_311

Oracle's (Sun) JDK and JRE installlables are executables that set those registry values. If your JRE installable was just a zip file and it did not set those registry values, this is an example of how _tc_javaplugin.ini_ can be configured:

[GENERAL]
LANGUAGE=EN

[JVM]
JAVA.OPTIONS=
JAVA.TC.JAVALIB=-Dtc.java.lib=%COMMANDER_PATH%/plugins/wcx/JavaDecompiler/javalib
JAVA.CLASS.PATH=-Djava.class.path=%COMMANDER_PATH%/plugins/wcx/JavaDecompiler/javalib/tc-classloader-2.2.jar
JVM_DLL=c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll
JVM_HOME=c:\Program Files\Java\jre1.8.0_311

[WCX]
CLASS=moi.tcplugins.decompiler.Decompiler

Tha Java plugin interface and derived plugins were tested on Oracle (Sun) JRE 1.8 (jre-8u311-windows-x64.exe). I've tried a few OpenJDKs versions and I'm getting an error "Starting the Java Virtual Machine failed . status =-6". I am opening new issues for that , also documenting all this in the main README page. Plese let me know if this works or does not work for you, and for which JREs/JDKs.

Regards, Moises

pdario commented 2 years ago

Hello Moises!

Unfortunately, no luck!

This is the massage now: [image: image.png]

Moreover, I installed JDK/JRE with Windows installer and the registry entries are present: [image: image.png]

Any idea?

On Sun, Jan 2, 2022 at 4:24 PM moisescastellano @.***> wrote:

Ciao Dario, thanks for reporting this issue: Short answer:

Add these 2 properties to the [JVM] section in the [TOTALCMD-INSTALL-DIR]/wcx/JavaDecompiler/tc_javaplugin.ini file, changing the paths to your JRE install dir:

JVM_DLL=c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll JVM_HOME=c:\Program Files\Java\jre1.8.0_311

Let me know if that works. Long answer:

The Java plugin interface searchs for the JRE in two ways:

1.

In the Windows Registry, it searchs for the key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

there it queries for "JavaHome" and "RuntimeLib", e.g. my computer registry values:

JavaHome      C:\Program Files\Java\jre1.8.0_311
RuntimeLib        C:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll

2.

If those values do not exist, it searches for the config file: [PLUGIN_DIR]/tc_javaplugin.ini

in that file, in the [JVM] section, it searches for two properties:

JVM_DLL="c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll"
JVM_HOME="c:\Program Files\Java\jre1.8.0_311"

Oracle's (Sun) JDK and JRE installlables are executables that set those registry values. If your JRE installable was just a zip file and it did not set those registry values, this is an example of how tc_javaplugin.ini can be configured:

[GENERAL] LANGUAGE=EN

[JVM] JAVA.OPTIONS= JAVA.TC.JAVALIB=-Dtc.java.lib=%COMMANDER_PATH%/plugins/wcx/JavaDecompiler/javalib JAVA.CLASS.PATH=-Djava.class.path=%COMMANDER_PATH%/plugins/wcx/JavaDecompiler/javalib/tc-classloader-2.2.jar JVM_DLL=c:\Program Files\Java\jre1.8.0_311\bin\server\jvm.dll JVM_HOME=c:\Program Files\Java\jre1.8.0_311

[WCX] CLASS=moi.tcplugins.decompiler.Decompiler

Tha Java plugin interface and derived plugins were tested on Oracle (Sun) JRE 1.8 (jre-8u311-windows-x64.exe). I've tried a few OpenJDKs versions and I'm getting an error " Starting the Java Virtual Machine failed . status =-6". I am opening new issues for that, also documenting all this in the main README page https://github.com/moisescastellano/javadecompiler-tcplugin. Plese let me know if this works or does not work for you, and for which JREs/JDKs.

Regards, Moises

— Reply to this email directly, view it on GitHub https://github.com/moisescastellano/javadecompiler-tcplugin/issues/1#issuecomment-1003731983, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMLHC5A4JAMAZCKQL6UHRDUUBU4XANCNFSM5LBJ2DUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

moisescastellano commented 2 years ago

Hi!

I cannot see the images showing the error msg. Is your error "LoadLibrary Failed" or "Starting Java Virtual Machine failed"? Yesterday I opened this issue because the plugin is giving those errors with OpenJDK (also with a very specific Oracle JDK: jre-8u112.)

In that case, by now, recommendation is to install an Oracle (Sun) JDK/JRE version.

Otherwise, let me know what is your error message and which JRE are you using - also, I suppose your TCmd is 64 bits?

Regards Moises

pdario commented 2 years ago

Hello!

The error is "LoadLibrary Failed" and I have both JDK17 and JRE1.8 from Oracle. The error seems to point to the correct jvm.dll path; I have spaces in the path ("Program Files").

On Mon, Jan 3, 2022 at 9:53 PM moisescastellano @.***> wrote:

Hi!

I cannot see the images showing the error msg. Is your error "LoadLibrary Failed" or "Starting Java Virtual Machine failed"? Yesterday I opened this issue https://github.com/moisescastellano/tcmd-java-plugin/issues/2 because the plugin is giving those errors with OpenJDK (also with a very specific Oracle JDK: jre-8u112.)

In that case, by now, recommendation is to install an Oracle (Sun) JDK/JRE version.

Otherwise, let me know what is your error message and which JRE are you using - also, I suppose your TCmd is 64 bits?

Regards Moises

— Reply to this email directly, view it on GitHub https://github.com/moisescastellano/javadecompiler-tcplugin/issues/1#issuecomment-1004351705, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMLHC7MGRYOCSAHLBHCOI3UUIEERANCNFSM5LBJ2DUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

moisescastellano commented 2 years ago

Hi Dario:

Yes, I can reproduce the issue with JRE8_112: first it says "JRE is not installed" -in spite it is in the registry- then when the JVM_DLL and JVM_HOME are stablished it says "LoadLibrary Failed".

For the first one I will keep this issue open; for the second one I opened the other one at: https://github.com/moisescastellano/tcmd-java-plugin/issues/2

In the meanwhile, if you wanna give it a try, some working (Oracle JREs) versions are: jre1.8.0_211, jre-8u311-windows-x64

Regards Moises

moisescastellano commented 2 years ago

I am also discussing / asking for help with these issues at this post in the TC forum.

pdario commented 2 years ago

Hello,

thanks for your reply, but I confirm the issue is presente with Oracle jre1.8.0_311.

Dario

On Tue, Jan 4, 2022 at 12:02 PM moisescastellano @.***> wrote:

Hi Dario:

Yes, I can reproduce the issue with JRE8_112: first it says "JRE is not installed" -in spite it is in the registry- then when the JVM_DLL and JVM_HOME are stablished it says "LoadLibrary Failed".

For the first one I will keep this issue open; for the second one I opened the other one at: moisescastellano/tcmd-java-plugin#2 https://github.com/moisescastellano/tcmd-java-plugin/issues/2

In the meanwhile, if you wanna give it a try, some working (Oracle JREs) versions are: jre1.8.0_211, jre-8u311-windows-x64

Regards Moises

— Reply to this email directly, view it on GitHub https://github.com/moisescastellano/javadecompiler-tcplugin/issues/1#issuecomment-1004713666, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMLHC2K3W6QLNOUJKMX6BDUULHT5ANCNFSM5LBJ2DUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

moisescastellano commented 2 years ago

Hi, sorry to hear that, maybe I missed something but I double checked in two computers that version works with this java plugin, did you remove the JVM_DLL and JVM_HOME properties to previous JRE in tc_javaplugin.ini? did you restarted TC after installing? is the registry now pointing to jre1.8.0_311?

Moises

pdario commented 2 years ago

I never changed JRE version, I always had jre1.8.0_311; I now removed the entries in the ini file and now the error is: JRE is not installed.

The registry correctly points to the JRE.

Dario

On Tue, Jan 4, 2022 at 2:09 PM moisescastellano @.***> wrote:

Hi, sorry to hear that, maybe I missed something but I double checked in two computers that version works with this java plugin, did you remove the JVM_DLL and JVM_HOME properties to previous JRE in tc_javaplugin.ini? did you restarted TC after installing? is the registry now pointing to jre1.8.0_311?

Moises

— Reply to this email directly, view it on GitHub https://github.com/moisescastellano/javadecompiler-tcplugin/issues/1#issuecomment-1004796569, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMLHC27PUOFMH7A3J3L6TTUULWRDANCNFSM5LBJ2DUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

moisescastellano commented 2 years ago

OK. I will try to investigate further. At least I can replicate this error with the JRE1.8_112 version in my computer. Thanks again for reporting

pdario commented 2 years ago

Ok, I'll wait for your update then, thank you.

Dario

On Tue, Jan 4, 2022 at 3:09 PM moisescastellano @.***> wrote:

OK. I will try to investigate further. At least I can replicate this error with the JRE1.8_112 version in my computer. Thanks again for reporting

— Reply to this email directly, view it on GitHub https://github.com/moisescastellano/javadecompiler-tcplugin/issues/1#issuecomment-1004841994, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMLHC3ZRXN7HR5JVQ22GBLUUL5QTANCNFSM5LBJ2DUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

NSP-0123456 commented 2 years ago

If you want to bypass jdk search, you must install javalib folder inside %commanderpath% and then use JVM section to define: JVM_DLL= JVM_HOME=

32bit/64bit are not compatible only one choice is possible with current version. If you use total commander 64bit , the properties must point to 64bit JVM, 32bit plugin will fall in loadlibrary error. The best practice I.M.O. is to have a common javalib folder inside total commander installation folder and not duplicate for each plugin (except for debug purpose)

java 1.8 remain the good choice developing java17 plugin with additional modules need to be handled by additional jvm parameters but the current implementation is not yet prepared for it.

moisescastellano commented 2 years ago

Hi Nsp:

Thanks for your post and email! While answering I've come to realize the reason for a couple errors I had in my plugins. I am asking you what do you think about a couple modifications, please let me know!

If you want to bypass jdk search, you must install javalib folder inside %commanderpath% and then use JVM section to define JVM_DLL= JVM_HOME=

That's correct, the exact jdk/jre search is, in this order:

  1. inside %COMMANDER_PATH%/javalib/tc_javaplugin.ini, JVM section, variables JVM_DLL and JVM_HOME
  2. in the Windows registry, key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
  3. in the tc_javaplugin.ini of plugin directory (e.g. %commanderpath%\plugins\wcx\JavaDecompiler\tc_javaplugin.ini), JVM section, variables JVM_DLL and JVM_HOME

I think the third way should be in fact before the second, so in case the variables exist they override the Windows default JRE configuration. What do you think?

If you use total commander 64bit , the properties must point to 64bit JVM, 32bit plugin will fall in loadlibrary error.

Yes, but in my tests I have been always using TC64bits and JREs 64 bits, still some of them fail with "LoadLibrary Failed" or "Starting Java Virtual Machine failed", as detailed here: https://github.com/moisescastellano/tcmd-java-plugin/issues/2

However this could be the thing with Dario: @Dario: I assumed you were using 64bits version for both TC and JREs, could you check it?

The best practice I.M.O. is to have a common javalib folder inside total commander installation folder

I have been publishing the plugins with javalib inside, so that people only have to enter the zip and the usual TC plugin installation process takes charge of everything. This implies javalib unzips under the plugin dir, not in the common folder.

In the old way (1.x) people had to: 1. un-tgz-ing the plugin, 2. installing it, 3. realizing it needs a javalib dir 4. searching for it in the web 5. un-tgz-ing and un-tar-ing javalib 6. manually copying it to tcmd dir I think that is too much for the average user just giving a try to the plugins. Providing javalib inside the plugin zip simplified the process a lot.

It is very important that javalib is unique per totalcmd installation. Only one JVM.dll can be safely loaded per TC process to avoid crash

The fact that only one JVM.dll is loaded is guaranteed by the .cpp code: search for this comment in java.cpp: // check if JVM is already running. That is not related to having one unique javalib dir.

Now, while answering you, I realized that there could be in fact a problem with multiple javalib dirs: the PluginClassLoader creates one class loader instance for the javalib dir, and then another one per each plugin dir. If there is more than one plugin, just the javalib of the first plugin is loaded. I was getting some random errors, I have now realized the problem was happening depending on which plugin was loaded first - and therefore which javalib.

For me the best solution is:

What do you think?

NSP-0123456 commented 2 years ago

Your conclusion seems to be to good ones for me.

Inside javalib, you can also add some common libraries like logging it is also a place to add native libraries in the ext or ext64 folder. This have to be explained by each plugin developer.

What should be provided by Christian is the javalib. And each new java plugin provider should link to the official javalib. If not, you can also create a specific git repository for the DLL and the javalib. (all the common) The javalib installation can be done with a dummy wdx plugin that return some info from the JVM and turn on the mixed mode for wlx if per monitor dpi is enabled...

What could be provided as a Dev Helper for java plugin, is the the common dll and some script to prepare a folder structure and help to pack the plugin with installer for TC.

moisescastellano commented 2 years ago

Yes, there is the git repository for the Java plugin interface, aimed to host all the common code. I will provide in a separate folder the last version of javalib, basically the pluginClassLoader. Logging is disabled by default, but the SL4J API could be also there.

Regarding the Dev Helper I am thinking of a very basic plugin, maybe a new version of Ken Handel's Hello World, or a new one.

pdario commented 2 years ago

Hello! I was using TC 32Bit with JRE 64 bit! I switched to TC 64bit and now it works, thank you!

moisescastellano commented 2 years ago

Hi! Great! I think now we can now close this issue, but previously I will write a Troubleshooting guide with this and other problems and solutions and I will link it here. Thanks for reporting this issue!

moisescastellano commented 2 years ago

I have now created a Troubleshooting guide including this issue, so I will close it.