Converting java based plugins to 64-bit

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, sheep, Hacker, Stefan2

moisescastellano
Junior Member
Junior Member
Posts: 27
Joined: 2021-12-05, 19:11 UTC

Converting java based plugins to 64-bit

Post by *moisescastellano »

(Edit for people new to this thread, find below original post)

With this post I asked help for recompiling the Java Plugin Interface 1.7 to be usable in TC 64 bits.
Fortunately Ghisler (author of TC) stepped in to help, and some new versions and Java plugins have been released since then.

Download and resources
--------------------
- Java plugin examples 64 bits
- Page of java plugin interface at totalcmd.net
- This is a work in progress, you can help with things to do
- History of changes

Original post
----------------
Hi:
I think the Java Plugin Interface by Ken Handel was always very underrated:

It was aimed to allow writing Total Commander plugins (WLX and WFX, WDX and WCX) in Java.
This would be very useful for people like me, with lots of Java background, but almost everything regarding Visual C++ / Pascal forgotten long ago.

I have an idea of a packer plugin I could do very easily in Java, as I developed 15 years ago the source code for packing as a (Java) standalone application; can provide details if anyone interested.
Also Ken Handel provided a lot of java plugin examples for any kind: lister, packer, file system and content. This guy was a genious!

However the developer abandoned the project in 2007 (yes, 14+ years ago!), and he has been unreachable since then (some people tried to reach him long ago).
Now, the main problem with this, is of course 64-bit versions of this plugin is no available, because as said the project was abandoned in 2007 and 64-bit tcmd came aroun 2011.

I have tried to generate a 64-bit version of his plugin, at least for the "WCX" (packer plugin) version.
Handel left the source code (Visual C++) for all the plugin versions here: http://java.totalcmd.net/V1.7/Projects.tgz
I think the license allows for recompiling and modifying it.
I checked also the help in Ghisler post here

So I downloaded Visual Studio 2022, and I was able to generate a .dll file compiled for x64
I rename that .dll to .wcx64, then zipped it within the example JCatalogue.tgz Hansel provided.
Total Command recognized it as a 64-bit plugin and installed it, so I was optimistic...
but then every time I tried to compress something, it crashed badly.

My knowledge of Visual Studio and C++ is little and obsolete, so I spent a lot of time just trying to recompile this dll and I am not able to see why is it crashing Total Commander.
So now I am giving up, and this post is muy white flag, unless someone think this revival is interesting and could help somehow.

Thanks
Last edited by moisescastellano on 2022-01-04, 11:46 UTC, edited 1 time in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

I have tried to compile Projects.tgz with Visual Studio 2017, but get an error about the following files missing:
jni.h
jawt.h
jawt_md.h

I guess that I need some kind of Java Native Interface SDK, but when I search for it, I only find information about the reverse direction (calling C/C++ code from Java). Did you install anything extra to compile this?
Author of Total Commander
http://www.ghisler.com
moisescastellano
Junior Member
Junior Member
Posts: 27
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

Hi Christian, thanks so much for tackling this!

You are right, those files are for Java Native Interface, they come along in every JDK (Java Development Kit) at these dirs:
  • [...]\jdk-xxx\include
  • [...]\jdk-xxx\include\win32
The fact that the second dir mentions win32 specific declarations made me wonder if something 32-bit was there, but the two header ".h" files inside are quite simple.

The JDK specific version does not matter as the files are basically the same along versions, in any case Ken Handel should be using JDK 1.6 by then.

So I just added those JDK dirs in Visual Studio at: [Project properties] --> [C/C++] / General / Additional Include Directories

In case you dont have a JDK installed:
  • you can download it here (unfortunately Oracle register is required, then you have to install it as no zip is available)
  • otherwise, I found them in this dir of github project, (I checked the files and they are the original ones with no changes, just click the "Raw" button to download, also there is the Win32 dir)
  • otherwise, let me know if I can attach here as code (about 10 kb) or email (?) you these files
Nothing more is needed to compile the Projects.tgz

Thanks!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

Thanks, I can compile it like that. But I'm not getting any further:
I have tried to install one of the plugins by Ken Handel in the 32-bit version of TC, but I get an error already during installation:
TC Java Plugin Error
---------------------------
Class not found class='tcclassloader/PluginClassLoader'. Please korrect the class name and/or the classpath of the INI file.
Initialization failed in class '' constructor '<init>' (signature='()V'). Please correct the Plugin class and Restart Total Commander.
1. Were you able to install and use any of these plugins with Total Commander 32-bit?
2. If yes, how? Maybe I need to install an older JRE?
Author of Total Commander
http://www.ghisler.com
moisescastellano
Junior Member
Junior Member
Posts: 27
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

The "class not found" error you got refers to a class inside "tc-classloader-1.2.jar", which in turn is inside javalib.tgz, and should be uncompressed in the (32-bit) TotalCommander installation directory (so having a [...]\totalcmd32\javalib dir). In the README.txt file inside the plugins, Handel says: "You must have installed additional libraries first BEFORE installing any Java plugin, if not, do it now and re-install."

If you still get that error, note:
That jar file is in turn referenced in file: [...]\totalcmd\plugins\wcx\JCatalogue\tc_javaplugin.ini
at this property:

Code: Select all

JAVA.CLASS.PATH=-Djava.class.path=%COMMANDER_PATH%/javalib/tc-classloader-1.2.jar
This should not be a problem, as TC32 sets a %COMMANDER_PATH% value of his own. However because TC32 suggests installing plugins under the TC64 installation directory, if you installed there the Java plugin, I would suggest uncompressing javalib also under TC64 dir, just in case.

Regarding JDK versions: I had only JDK 1.8 (including JRE), yet the Java Plugin complained that I did not have JRE installed. In the code (java.cpp, java.h) it searchs the registry to find the JRE, at "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment", which again I already had correctly set.

Anyway I installed JDK 1.6, and the plugin installed correctly, in spite everything (JAVA_HOME, registry...) still pointing to JRE 1.8. I did not find the reason, but:

With the tips above, I am using JCatalogue example Java plugin correctly in TC 32-bit.

I guess these installation problems and manual actions have prevented a lot of people from trying (and developing for) the Java plugin. I would try (yet I do not know how) improving the installation process if/when we 64-revive it.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

I managed to compile it for 64-bit now, with only minor changes:
https://www.totalcommander.ch/win/packer/JCatalogue64.zip

1. I had to disable optimizations, it crashes with optimizations on
2. I changed the runtime library to Multi-threaded /MT instead of Multi-threaded-DLL. The latter does not mean that it's a library to create a dll. It means that it uses the Microsoft VCC runtime libraries.
3. I get warnings that HWND (8 bytes) is converted to a smaller variable jint (4 bytes). But to my knowledge, Windows uses only the lower 32-bit of a Windows handle to have compatible handles between 32-bit and 64-bit programs. Therefore it should work fine.

I haven't tried the 64-bit dll with other types of plugins yet.
Author of Total Commander
http://www.ghisler.com
moisescastellano
Junior Member
Junior Member
Posts: 27
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

Awesome!
Thanks Christian, we have this ancient plugin working again! - also I will develop muy own Java plugin now.
I managed to compile it for 64-bit now, with only minor changes
I tried those changes in Visual Studio 2022, yet with my DLL compiled like that TC says it is not a valid plugin. I am downloading VS2017 just out of curiosity and because self-steem hurts.
I haven't tried the 64-bit dll with other types of plugins yet.
As you imply, this same dll-wcx64 file can be used exactly as is, at least for other wcx (java) plugins. I have tried, besides JCatalogue64, DirCBM (also a wcx plugin), and 64-bit works fine for unpackaging. For packaging, it throws an exception, BUT this also happens in the 32-bit version, so I think DirCBM was ever only able to *show* the contents of C64 disk images, and that works.

I have not tried other types (wfx, wlx, wdx) because I don't have them downloaded and totalcmd.net is down since a couple days ago. For these, I think also the dll should be the same as it includes all the functions for every plugin type, but I remember the 32-bit wcx was not the same binary in some of them; I guess just for historical reasons. I will check the wcx64 in them when available.

So I think what remains to be done to make this publicly available is:

1. doc: new version number, obviously refering to the original plugin and credit Handel; credit you Ghisler for recompiling, etc.
2. re-package, including 64-bit dll and docs, and test every Ken Handel plugin. Improvement: I have found "javalib" dir can be included inside the plugin zip, just changing tc_javaplugin.ini. Yes, it duplicates a few jars if you have more than one java plugin, but it reduces the installation process to the usual one without strange errores, and what do 3Mb suppose nowadays?
3. upload: at totalcmd.net this is a very special plugin, as it has the javadoc pages, the samples page with several sub-plugins... Otherwise, would you like this plugin in ghisler.com? I am not sure what is the criteria for hosting them here

Comments / suggestions?
I can proceed with those points (when totalcmd.net is up again)
User avatar
Flint
Power Member
Power Member
Posts: 3387
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Re: Converting java based plugins to 64-bit

Post by *Flint »

moisescastellano wrote: 2021-12-08, 16:46 UTCtotalcmd.net is down since a couple days ago.
While it's down, you can use a backup service located at https://ru.wincmd.com/tcbak/
More details here: viewtopic.php?p=404877#p404877
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.00 / Win7 x64 SP1, Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

2moisescastellano
I can send you my changes for Visual Studio 2017 if you can't make it work yourself, just contact me by e-mail (support at ghisler dot com).
Maybe the errors shown when the javalib is missing should be reworded to tell the user that they need to download them.
Also it needs to be made clear that the 64-bit plugin needs an installed 64-bit JRE. I first had only used the Web installer from Firefox (which is 32-bit), so it only installed the 32-bit JRE.
I didn't have to modify the javalib at all, so it can remain on totalcmd.net. However, the plugins will have to be updated to include the 64-bit dll.
Author of Total Commander
http://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8647
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Converting java based plugins to 64-bit

Post by *MVV »

I think it would be useful to move discussion about JAVA plugins to a separate topic... (and to delete my this one)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

Good idea - but I will leave your suggestion here so people understand why this happened.
Author of Total Commander
http://www.ghisler.com
moisescastellano
Junior Member
Junior Member
Posts: 27
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

Now that totalcmd.net is up again, I have downloaded all the (19) java plugins by Handel, and repackaged with the following:

Changes to every original 32-bit java plugin by Ken Handel:
======================================================

- included the new (wcx64 / wfx64 / wlx64 / wdx64) dll, recompiled by Ghisler (author of Total Commander), from Handel sources
- included the javalib dirs. Now every Java plugin installs just entering the zip, without further ado
- modified tc_javaplugin.ini accordingly (to refer the new location of javalib)
- included a text file like with some extra info for the 64-version
ghisler(Author) wrote: 2021-12-09, 09:50 UTC I didn't have to modify the javalib at all, so it can remain on totalcmd.net. However, the plugins will have to be updated to include the 64-bit dll.
Correct. I just also included the javalib in every java plugin. I think (very) few people has ever followed the old process of
  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.
Maybe because of that, he plugin was not very popular ever. Now every Java plugin installs just entering the zip, without further ado.

2Flint: Can you tell me how to proceed to upload all them at totalcmd.net?
User avatar
Flint
Power Member
Power Member
Posts: 3387
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Re: Converting java based plugins to 64-bit

Post by *Flint »

2moisescastellano
You need an account for that. Please, send me all the details listed here, and I'll create it for you.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.00 / Win7 x64 SP1, Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 41868
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Converting java based plugins to 64-bit

Post by *ghisler(Author) »

To avoid the duplication of the java library, I could modify the plugin to send the user to a download page, what do you think? The java lib could be improved by adding an install.inf with the type=EXE.
Author of Total Commander
http://www.ghisler.com
User avatar
Flint
Power Member
Power Member
Posts: 3387
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Re: Converting java based plugins to 64-bit

Post by *Flint »

Do you mean updating/replacing the plugin on the original page at https://totalcmd.net/plugring/tc_java.html ? That would require the original author to agree to it and accept the new variant, so he could publish it as an update (or an admin like me could publish it from his name). Otherwise it would be a bit against what totalcmd.net is doing. It's designed to be a platform for people publishing their own plugins; and replacing someone's plugin by someone else's adaptation will be confusing. Usually when a fork appears, the new developer simply puts it into description, what his plugin was derived from and what the differences from the original are. That does increase the amount of similar works, but generally seems to have worked fine so far.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.00 / Win7 x64 SP1, Win10 x64
Post Reply