-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAssistantJavaControl.pas
More file actions
85 lines (70 loc) · 2.57 KB
/
AssistantJavaControl.pas
File metadata and controls
85 lines (70 loc) · 2.57 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{**
@Abstract Êîíòðîë äëÿ âûâîäà ñîîáùåíèé Java ïðîãðàìì
@Author Prof1983 <prof1983@ya.ru>
@Created 07.04.2007
@LastMod 13.11.2012
}
unit AssistantJavaControl;
interface
uses
ABase, AJavaControl, JavaRuntime;
function AssistantJavaControl_RunAction(): AError;
implementation
var
{** Êîíòðîë âûïîëíåíèÿ Java ïðîãðàììû (íå ðàáîòàåò) }
FJavaControl: TJavaControl;
// --- Public ---
function AssistantJavaControl_Init(): AError;
begin
xxx
end;
function AssistantJavaControl_RunAction(): AError;
var
Strings: TStringList;
Runtime: TJavaRuntime;
begin
// jtest1
{*******************************************************}
{ }
{ JNI Wrapper for Delphi Demo }
{ Demonstrates about the Simplest }
{ possible use of the JNI Wrapper. }
{ }
{ The main in HelloWorld.java simply spits }
{ back the strings it receives. This wrapper }
{ allows you to use TStringList to pass the }
{ arguments. CallMain is a convenience method. }
{ }
{ Copyright (c) 1998 Jonathan Revusky }
{ }
{ Java and Delphi Freelance programming }
{ jon@revusky.com }
{ }
{*******************************************************}
// example that shows to launch a class
// using the JavaRuntime unit.
{ $APPTYPE CONSOLE}
//uses
// SysUtils, Classes, JavaRuntime;
FJavaControl := TJavaControl.Create();
FJavaControl.Control := AddMainTab(0, 'Java');
FJavaControl.Initialize();
FJavaControl.AddToLog(lgGeneral, ltInformation, '=== Íà÷àëî ===');
try
Strings := TStringList.Create();
Strings.Add('Hello, world.');
Strings.Add('Salut, monde.');
Strings.Add('Hola, mundo.');
Runtime := TJavaRuntime.GetDefault(); // Ïîëó÷àåì ñðåäó ïî óìîë÷àíèþ
FJavaControl.AddToLog(lgGeneral, ltInformation, 'ClassPath: ' + Runtime.Classpath);
Runtime.Printf := FJavaControl.Printf; // Íàçíà÷àåì ïðîöåäóðó äëÿ âûâîäà ñîîáùåíèé
Runtime.CallMain('HelloWorld', Strings); // Âûïîëíèòü HelloWorld.main(Strings)
Runtime.Wait(); // Æäåì îêîí÷àíèÿ âûïîëíåíèÿ
Strings.Free();
except
// on EJvmException do
// ShowException(ExceptObject, ExceptAddr);
end;
FJavaControl.AddToLog(lgGeneral, ltInformation, '=== Êîíåö ===');
end;
end.