Platforms to show: All Mac Windows Linux Cross-Platform

Next items

JavaClassMBS.AllocateObject as JavaObjectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Allocates a new Java object without invoking any of the constructors for the object. #
Notes:
Returns a reference to the object or nil on any error.

Does not work for array classes.
Throws InstantiationException if the class is an interface or an abstract class.

Feedback, Comments & Corrections

JavaClassMBS.CallStaticBooleanMethod(MethodID as JavaMethodMBS, args as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a boolean return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticByteMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a byte return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticCharMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a char return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticDoubleMethod(MethodID as JavaMethodMBS, args as memoryblock) as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a double return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticFloatMethod(MethodID as JavaMethodMBS, args as memoryblock) as single
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a float return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticIntMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with an integer return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticLongMethod(MethodID as JavaMethodMBS, args as memoryblock) as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 11.3 Yes Yes Yes Yes No
Function: Calls a static method with a long return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticMain(args() as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static main method and passes the String array.

Feedback, Comments & Corrections

JavaClassMBS.CallStaticMethod(MethodID as JavaMethodMBS, args() as Variant) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 19.4 Yes Yes Yes Yes No
Function: Calls a static method.
Example:
Dim vm As JavaVMMBS // your initialized VM

// 1. Find class
Dim jclass As JavaClassMBS =vm.FindClass("stringtest")

if jclass=nil then
msgbox "Can't find stringtest class"
Return
end if

// 2. lookup method
Dim jmethod3 As JavaMethodMBS = jclass.GetStaticMethod("setValue","(Ljava/lang/String;)V")
if jmethod3=nil then
MsgBox "Failed to find setValue method."
Return
end if

// 3. Call static method
Dim param3() As Variant
param3.append "Hello World"
Call jclass.CallStaticMethod(jmethod3,param3)

MsgBox "done"
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args variant array that immediately follows the methodID argument.

This is generic version, where our plugin translates between native Xojo data types and Java data types. We support conversion of boolean, byte (integer), char (integer), short (integer), int (integer), long (int64), double, float (single) and Java objects. Objects can be JavaObjectMBS or subclasses including JavaStringMBS and the JavaArrayMBS subclasses. For your convenience you can pass in string and we convert to JavaStringMBS for you.

Feedback, Comments & Corrections

JavaClassMBS.CallStaticObjectMethod(MethodID as JavaMethodMBS, args as memoryblock) as JavaObjectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with an object return value.
Example:
dim e as JavaVMMBS // global

// Call "public static String getMessage()" and "public static void setMessage(String theMessage)" from class "test".

dim jclass, sclass as JavaClassMBS
dim jmethod as JavaMethodMBS
dim jstring as JavaStringMBS
dim args as JavaObjectArrayMBS
dim m as MemoryBlock
dim s as String
dim jfield as JavaFieldMBS

jclass=e.FindClass("test")

if jclass=nil then
msgbox "Can't find test class"
else
jmethod = jclass.GetStaticMethod("setMessage", "(Ljava/lang/String;)V")

if jmethod=nil then
msgbox "Can't find HelloWorld.setMessage"
else
jstring = e.NewStringUTF8("Hello from Xojo!")
if jstring=nil then
msgbox "Out of memory"
else
m=NewMemoryBlock(8) // 8 bytes per parameter
m.long(0)=jstring.Handle

jclass.CallStaticVoidMethod(jmethod, m)

jmethod = jclass.GetStaticMethod("getMessage", "()Ljava/lang/String;")

if jmethod=nil then
msgbox "Can't find HelloWorld.getMessage"
else
m=NewMemoryBlock(8) // 8 bytes per parameter
m.long(0)=jstring.Handle

jstring=JavaStringMBS(jclass.CallStaticObjectMethod(jmethod,m))

MsgBox jstring.CopyStringUTF
end if
end if
end if
end if
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticShortMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with a short return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.CallStaticVoidMethod(MethodID as JavaMethodMBS, args as memoryblock)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Calls a static method with no return value.
Notes:
This call invokes a static method on a Java object, according to the specified method ID. The methodID argument must be obtained by calling JavaClassMBS.GetMethod().

The method ID must be derived from this class, not from one of its superclasses.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Feedback, Comments & Corrections

JavaClassMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 13.1 Yes Yes Yes Yes No
Function: The private constructor.

Feedback, Comments & Corrections

JavaClassMBS.GetField(name as string, sig as string) as JavaFieldMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Searches for the Field with the given Name and Signature.
Notes:
Nil on any error.

The signature is a string derived from the field's type or method's arguments and return type, as shown here:

Java TypeSignature
boolean Z
byte B
char C
short S
int I
long L
float F
double D
void V
objects Lfully-qualified-class-name;
arrays [array-type
methods (argument-types)return-type

Feedback, Comments & Corrections

JavaClassMBS.GetMethod(name as string, sig as string) as JavaMethodMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Searches the method with the given name and signature.
Example:
dim jclass as JavaClassMBS
dim method as JavaMethodMBS

method=jclass.GetMethod("mymethod", "([Ljava/lang/String;)V")
Notes:
Returns the method ID for an instance (non-static) method of a class or interface. The method may be defined in one of the the class's super classes and inherited by the class. The method is determined by its name and signature.

To obtain the method ID of a constructor, supply <init> as the method name and void (V) as the return type.

Nil on any error.

Throws NoSuchMethodError if the specified method cannot be found.

The signature is a string derived from the field's type or method's arguments and return type, as shown here:

Java TypeSignature
boolean Z
byte B
char C
short S
int I
long L
float F
double D
void V
objects Lfully-qualified-class-name;
arrays [array-type
methods (argument-types)return-type

Feedback, Comments & Corrections

JavaClassMBS.GetStaticField(name as string, sig as string) as JavaFieldMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Searches the static field with the given name and signature.
Notes: Nil on any error.

Feedback, Comments & Corrections

JavaClassMBS.GetStaticMethod(name as string, sig as string) as JavaMethodMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Returns the method ID for a static method of a class. The method is specified by its name and signature.
Example:
dim jclass as JavaClassMBS
dim method as JavaMethodMBS

method=jclass.GetStaticMethod("main", "([Ljava/lang/String;)V")
Notes:
Nil on any error.
e.g. the signature of the default static main method is "([Ljava/lang/String;)V" which means return type void at the end and before an array of string.

Feedback, Comments & Corrections

JavaClassMBS.NewObject(methodID as JavaMethodMBS, args as memoryblock) as JavaObjectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Constructs a new Java object.
Notes:
The method ID indicates which constructor method to invoke. This ID must be obtained by calling GetMethod with <init> as the method name and void (V) as the return type.

Returns nil on any error.

Programmers place all arguments to the method in an args memoryblock that immediately follows the methodID argument.
In the memoryblock you need to use 8 bytes per argument and align them correctly. (alignment depends on platform)

Throws Java InstantiationException if the class is an interface or an abstract class.

See also:

Feedback, Comments & Corrections

JavaClassMBS.NewObject(MethodID as JavaMethodMBS, args() as Variant) as JavaObjectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Java MBS Java Plugin 19.4 Yes Yes Yes Yes No
Function: Constructs a new Java object.
Example:
dim vm as JavaVMMBS // your initialized VM

// 1. Find class
Dim jclass As JavaClassMBS=vm.FindClass("stringtest")

If jclass = Nil Then
MsgBox "Can't find stringtest class"
Return
End If

// 2. Call constructor
Dim jmethod As JavaMethodMBS = jclass.GetMethod("<init>", "(ILjava/lang/String;D)V")

If jmethod = Nil Then
MsgBox "Can't find constructor"
Return
End If

Dim param() As Variant
// 1. Parameter with Integer: I
param.Append 123
// 2. Parameter with string: Ljava/lang/String;
param.Append "Hello World"
// 3. Parameter with double: D
param.Append 3.14
Dim jobject As JavaObjectMBS = jclass.NewObject(jmethod, param)

If jobject = Nil Then
MsgBox "Constructor failed!?"
Else
MsgBox "OK: "+jobject.ClassName
End If
Notes:
The method ID indicates which constructor method to invoke. This ID must be obtained by calling GetMethod with <init> as the method name and void (V) as the return type.

Returns nil on any error.

Programmers place all arguments to the method in an args variant array that immediately follows the methodID argument.

Throws Java InstantiationException if the class is an interface or an abstract class.

This is generic version, where our plugin translates between native Xojo data types and Java data types. We support conversion of boolean, byte (integer), char (integer), short (integer), int (integer), long (int64), double, float (single) and Java objects. Objects can be JavaObjectMBS or subclasses including JavaStringMBS and the JavaArrayMBS subclasses. For your convenience you can pass in string and we convert to JavaStringMBS for you.

See also:

Feedback, Comments & Corrections

JavaClassMBS.StaticBooleanField(TheField as JavaFieldMBS) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static boolean field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticByteField(TheField as JavaFieldMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static byte field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticCharField(TheField as JavaFieldMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static char field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticDoubleField(TheField as JavaFieldMBS) as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static double field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticField(TheField as JavaFieldMBS) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 19.4 Yes Yes Yes Yes No
Function: Get or set the value for a static field in this class.
Example:
Dim jclass As JavaClassMBS=vm.FindClass("stringtest")

If jclass = Nil Then
MsgBox "Can't find stringtest class"
Return
End If

Dim field As JavaFieldMBS = jclass.GetField("Name", "Ljava/lang/String;")
Dim v As Variant = jclass.StaticField(field)
Dim js As JavaStringMBS = v
MsgBox js
Notes:
This is generic version, where our plugin translates between native Xojo data types and Java data types. We support conversion of boolean, byte (integer), char (integer), short (integer), int (integer), long (int64), double, float (single) and Java objects. Objects can be JavaObjectMBS or subclasses including JavaStringMBS and the JavaArrayMBS subclasses. For your convenience you can pass in string and we convert to JavaStringMBS for you.

Do not use for generic fields!
(Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticFloatField(TheField as JavaFieldMBS) as single
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static float field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticIntField(TheField as JavaFieldMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static integer field in this class.
Example:
dim f as FolderItem

f=SpecialFolder.Desktop.Child("ojdbc14.jar")

dim j as new JavaVMMBS(f)

dim c as JavaClassMBS = j.FindClass("oracle/jdbc/driver/OracleTypes")

dim field as JavaFieldMBS

// this are all static integer fields in this class:

field = c.GetStaticField("CURSOR","I")
MsgBox str(c.StaticIntField(field))

field = c.GetStaticField("BLOB","I")
MsgBox str(c.StaticIntField(field))

field = c.GetStaticField("DOUBLE","I")
MsgBox str(c.StaticIntField(field))
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticLongField(TheField as JavaFieldMBS) as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 11.3 Yes Yes Yes Yes No
Function: Get or set the value for a static long field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

JavaClassMBS.StaticObjectField(TheField as JavaFieldMBS) as JavaObjectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Java MBS Java Plugin 4.3 Yes Yes Yes Yes No
Function: Get or set the value for a static object field in this class.
Notes: (Read and Write computed property)

Feedback, Comments & Corrections

Next items

The items on this page are in the following plugins: MBS Java Plugin.

The biggest plugin in space...




Links
MBS Xojo Chart Plugins