 
							Intro
Java4Delphi converter tool helps to convert Java .class files and Java .jar archives to Delphi .pas files. So, Java classes and libraries can be used from Delphi projects easily.
Java4Delphi by WINSOFT is a commercial tool and gives all the functionalities when you get a license. All the source code of JNI and Delphi4Java units will be included in it.
The best thing about this tool is it utilizes classes with automatic reference-counting memory management.
Currently, this tool is available all the Delphi versions except the latest one Sydney, but be sure to check in near future for a new update.
Specifications
- Supported OSs: All
- Available for Delphi & C++ Builder 6-10.4
How to use it?
If you would like to learn more about this tool here you can watch the demo action video which shows how to convert Java files into Delphi .pas units.
To convert Java files, you should use the command-line tool to execute the java4delphi.exe program. Just go to the folder which java4delphi.exe is on and write java4delphi.exe and give the Java file name or path.

Here is our result:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | {$WARN UNSAFE_TYPE OFF} {$WARN UNSAFE_CODE OFF} unit Test_class; interface uses JNI, Java4Delphi; type   Itest_Test = interface;   Ttest_Test = class;   Itest_Test = interface(Ijava_lang_Object)   end;   Ttest_Test = class(Tjava_lang_Object, Itest_Test)   protected   public     constructor Create(JavaObject: JObject); overload;   end;   Ttest_TestClass = class(Tjava_lang_ObjectClass)   protected     constructor Create(const ClassName: AnsiString; Initialize: Boolean);   public   end; function Get_test_TestClass: Ttest_TestClass; implementation var test_TestClass: Ttest_TestClass; constructor Ttest_Test.Create(JavaObject: JObject); begin   Get_test_TestClass;   inherited Create(JavaObject); end; function Get_test_TestClass: Ttest_TestClass; begin   if test_TestClass = nil then     test_TestClass := Ttest_TestClass.Create('test/Test', True);   Result := test_TestClass; end; constructor Ttest_TestClass.Create(const ClassName: AnsiString; Initialize: Boolean); begin   inherited Create(ClassName, False); end; initialization finalization   test_TestClass.Free; end. | 
So how we can use this module in our projects? The answer is simple. First, you should call CreateJavaVM before starting to use the converted unit.
Then you can create an instance from the Itest_Test interface:
| 1 2 3 4 5 6 7 | var   Test: Itest_Test; begin   ...   Test := Ttest_Test.Create;    ... end; | 
And here is our full implementation and use case:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | uses JNI, Java4Delphi, Test_class; {$R *.dfm} var JavaVMInitialized: Boolean; procedure TFormMain.ButtonTestClick(Sender: TObject); var Test: Itest_Test; begin   if not JavaVMInitialized then   begin     CreateJavaVM(JNI_VERSION_1_8, '-Djava.class.path=' + GetCurrentDir);     JavaVMInitialized := True;   end;   Test := Ttest_Test.Create;   ShowMessage(Test.hello); end; | 
Head over and check out the full WINSOFT Java4Delphi tool!
Like what you see? You can get the Java4Delphi and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4.1 today!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition








