Reputation: 16363
There's Java jar binary library with described classes/functions making some usefull things (nothing special just plain Java - no JNI). No sources available.
There's a task to call those functions directly from Delphi. How to do that?
P.S. I know nothing about Delphi, but I know a lot about Java.
Upvotes: 8
Views: 5554
Reputation: 3941
As a fast and simpler alternative to the low level, time consuming and error prone JNI from Delphi option, you should try Java for Delphi.
You'll be working with an object oriented API, would need a fraction of the code when compared to JNI and solve your Delphi/Java integration problem in a few hours instead of days, weeks (or months depending on the use case).
As an example, below is the public declaration of the Delphi type corresponding to java.lang.String with a code extract showing how it can be used.
Don't hesitate to contact J4SOFT, will be glad to help you.
Procedure Sample;
var
AJavaString: Ijava_lang_String;
AValue: string;
begin
AJavaString := Tjava_lang_String.Create('A value');
AValue := AjavaString.ToString;
if AJavaString.StartsWith('A') then
...
end;
...
type
Tjava_lang_String = class(Tjava_lang_Object, Ijava_lang_String)
public
constructor Create;
constructor Create(p0: string);
constructor Create(p0: Ijava_lang_StringBuffer);
constructor Create(p0: Ijava_lang_StringBuilder);
constructor Create(p0: TjxByte1DArray);
constructor Create(p0: TjxByte1DArray; p1: Longint);
constructor Create(p0: TjxByte1DArray; p1: Longint; p2: Longint);
constructor Create(p0: TjxByte1DArray; p1: Longint; p2: Longint; p3: Longint);
constructor Create(p0: TjxByte1DArray; p1: Longint; p2: Longint; p3: string);
constructor Create(p0: TjxByte1DArray; p1: string);
constructor Create(p0: TjxChar1DArray);
constructor Create(p0: TjxChar1DArray; p1: Longint; p2: Longint);
constructor Create(p0: TjxInt1DArray; p1: Longint; p2: Longint);
function CharAt(p0: Longint): Char;
function CodePointAt(p0: Longint): Longint;
function CodePointBefore(p0: Longint): Longint;
function CodePointCount(p0: Longint; p1: Longint): Longint;
function CompareTo(p0: string): Longint;
function CompareToIgnoreCase(p0: string): Longint;
function Concat(p0: string): string;
function ContentEquals(p0: Ijava_lang_StringBuffer): Boolean;
class function CopyValueOf(p0: TjxChar1DArray): string;
class function CopyValueOf(p0: TjxChar1DArray; p1: Longint; p2: Longint): string;
function EndsWith(p0: string): Boolean;
function Equals(p0: Ijava_lang_Object): Boolean; reintroduce;
function EqualsIgnoreCase(p0: string): Boolean;
class function Format(p0: string; p1: Tjava_lang_Object1DArray): string;
function GetBytes: TjxByte1DArray;
procedure GetBytes(p0: Longint; p1: Longint; p2: TjxByte1DArray; p3: Longint);
function GetBytes(p0: string): TjxByte1DArray;
procedure GetChars(p0: Longint; p1: Longint; p2: TjxChar1DArray; p3: Longint);
function HashCode: Longint;
function IndexOf(p0: Longint): Longint;
function IndexOf(p0: Longint; p1: Longint): Longint;
function IndexOf(p0: string): Longint;
function IndexOf(p0: string; p1: Longint): Longint;
function Intern: string;
function IsEmpty: Boolean;
function LastIndexOf(p0: Longint): Longint;
function LastIndexOf(p0: Longint; p1: Longint): Longint;
function LastIndexOf(p0: string): Longint;
function LastIndexOf(p0: string; p1: Longint): Longint;
function Length_: Longint;
function Matches(p0: string): Boolean;
function OffsetByCodePoints(p0: Longint; p1: Longint): Longint;
function RegionMatches(p0: Longint; p1: string; p2: Longint; p3: Longint): Boolean;
function RegionMatches(p0: Boolean; p1: Longint; p2: string; p3: Longint; p4: Longint): Boolean;
function Replace(p0: Char; p1: Char): string;
function ReplaceAll(p0: string; p1: string): string;
function ReplaceFirst(p0: string; p1: string): string;
function Split(p0: string): TjxString1DArray;
function Split(p0: string; p1: Longint): TjxString1DArray;
function StartsWith(p0: string): Boolean;
function StartsWith(p0: string; p1: Longint): Boolean;
function Substring(p0: Longint): string;
function Substring(p0: Longint; p1: Longint): string;
function ToCharArray: TjxChar1DArray;
function ToLowerCase: string;
function ToString: string;
function ToUpperCase: string;
function Trim: string;
class function ValueOf(p0: Char): string;
class function ValueOf(p0: Double): string;
class function ValueOf(p0: Single): string;
class function ValueOf(p0: Longint): string;
class function ValueOf(p0: Int64): string;
class function ValueOf(p0: Ijava_lang_Object): string;
class function ValueOf(p0: Boolean): string;
class function ValueOf(p0: TjxChar1DArray): string;
class function ValueOf(p0: TjxChar1DArray; p1: Longint; p2: Longint): string;
property CASE_INSENSITIVE_ORDER;
end;
Upvotes: 1
Reputation: 3730
If you decompile binary file and produce some kind of a primitive java source, then you might consider using Java to Pascal converter. This should be doable without much trouble since you said that JAR is nothing special or complex.
Upvotes: 0
Reputation: 7722
Does the jar file contains a main class that can be called from the command line? If so problem solved Delphi can execute command line operations. If there is no main class you can create one that calls the original jar file.
Upvotes: 1
Reputation: 24483
No you can't the way to go is JNI.
A few resources:
Unless you have too much time on your hands, in which you could decompress the JAR files (they are ZIP files), write your own Java VM in Delphi and go from there ;-)
Upvotes: 6