moisescastellano / javadecompiler-tcplugin

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

Java Runtime Environment is not installed … #2

Open ChristianGruen opened 2 years ago

ChristianGruen commented 2 years ago

When trying to view a .class file, I get the following error message

Java Runtime Environment is not installed on this Computer! Please install JRE and Restart Total Commander.

I have installed various JDK instances (8, 11, 17), which all have a jre sub-directory.

Could your plugin be enhanced to also provide support for JDK installations?

moisescastellano commented 2 years ago

Hi Christian, thanks for reporting! Yes, the plugin should work with JDKs, it has been tested with Oracle JDK 1.8.0

This particular error is in the troubleshooting guide: https://moisescastellano.github.io/tcmd-java-plugin/troubleshooting

Short version of solution:

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

In your case, if the JRE is found inside the JDK, just point to the internal JRE dir. For more info, please check the guide.

Please let me know if this solution works for you, and also: JRE version, Total Commander version and for both if they are 32 or 64 bits.

Best Regards

ChristianGruen commented 2 years ago

Thanks, Moises, for your reply.

My initial configuration was:

Your link to the troubleshooting guide was helpful. I tried different combinations, and I think that of all the next issues I encountered were mentioned in your guide. As OpenJDK seems to cause issues, and as TC 32 and 64 should not be mixed, this is the configuration I ended up with:

With this combination, errors such as "JRE not found" or "LoadLibrary" disappeared, but I didn’t manage to look into any class file. When trying to unpack a file (via Enter or Ctrl-PageDown), the hourglass icon appears and nothing happens:

image

Here’s one of the example files that I wanted to browse: BaseX.zip

No problems arise with this file and the TC Jad Lister Plugin:

image

Apart from the latest observation, do you think there are chances to …

  1. get the plugin working with OpenJDK;
  2. get TC 32bit and Java 64bit working (I still use the latter, as there are various plugins that don’t exist for TC64); and
  3. automatically find an installed JDK/JRE?
moisescastellano commented 2 years ago

Hi Christian:

The CFR decompiler used by the plugin is also able to decompile that class.

I think the problem is that BaseX.class extends org/basex/core/CLI, which is not found in the classpath, so an exception is thrown when the plugin tries to get the elements of the class via java reflection. However this should just not to show the folders with the elements (methods, constructors): you should still be able to view the BaseX.java decompiled file.

I didn’t manage to look into any class file

Did you test also with classes not extending other non-JRE classes? (is it ok if they extend JRE standard classes).

the hourglass icon appears and nothing happens

Are you sure there is not a popup window waiting for you to accept or something?

I would ask you to enable logs, but in a couple days I will be releasing a new version of Java Decompiler plugin with a better exception management and other features, so if you dont mind just wait for it and lets check again with the new version. In this version (not yet released) I view correctly decompiled your class, just not the folders with methods as said before.

Regarding whether there are chances to …

  1. get the plugin working with OpenJDK;

This is in my TO-DO list. Unfortunately I don't know why the Visual C++ code fails to Load the Library for OpenJDK and I am not so familiar with C++ as with Java, so cannot provide an estimation for release.

  1. get TC 32bit and Java 64bit working (I still use the latter, as there are various plugins that don’t exist for TC64); and

Maybe can you use a Java 32 bit for TC32? I dont think that 32/64 bit mixing is possible.

  1. automatically find an installed JDK/JRE?

This is already done - the java plugin interface searchs in the Windows registry, key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment. Maybe you dont have that key in the registry, if your JDK was not installed with an executable? Could you check it?

ChristianGruen commented 2 years ago

just wait for it and lets check again with the new version

I’ll be happy to wait. Thanks for your comprehensive feedback and your efforts.

moisescastellano commented 2 years ago

Hi, version 1.1 of JavaDecompiler has been released, let me know if you can enter and view your BaseX.java decompiled class with this version!

ChristianGruen commented 2 years ago

I was successful with the new version (once again, with TC64 and Oracle JRE 8); thanks a lot!

image

This is in my TO-DO list. Unfortunately I don't know why the Visual C++ code fails to Load the Library for OpenJDK and I am not so familiar with C++ as with Java, so cannot provide an estimation for release.

I’m looking forward to your experiences with Visual C++ (unfortunately, I can’t really help).

This is already done - the java plugin interface searchs in the Windows registry, key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment. Maybe you dont have that key in the registry, if your JDK was not installed with an executable? Could you check it?

On my system, only the following paths are registered:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit
→ CurrentVersion=1.8

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8
→ JavaHome=C:\Program Files\Java\JDK8\

image

In addition to checking these registry keys, you could check for the existence of a JAVA_HOME environment variable, which is e.g. set by many Maven users (in particular if a portable version of Java has been installed).

In both cases, you can add a jre\ subdirectory to the path if the existing path lacks the required executables. Do you think the executables in the jdk\bin\ directory are doing their job, or do you exclusively need to work with the jdk\jre\bin executables?

moisescastellano commented 2 years ago

I was successful with the new version (once again, with TC64 and Oracle JRE 8); thanks a lot!

Great!

On my system, only the following paths are registered

Yes I could check for those in a next version, also for JAVA_HOME

Do you think the executables in the jdk\bin\ directory are doing their job, or do you exclusively need to work with the jdk\jre\bin executables?

I think the executables inside JRE should be used, even when it is a JDK

Thanks for reporting!