Platforms to show: All Mac Windows Linux Cross-Platform

Back to JavaClassMBS class.

JavaClassMBS.CallStaticBooleanMethod(MethodID as JavaMethodMBS, args as memoryblock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a boolean return value.

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)

JavaClassMBS.CallStaticByteMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a byte return value.

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)

JavaClassMBS.CallStaticCharMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a char return value.

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)

JavaClassMBS.CallStaticDoubleMethod(MethodID as JavaMethodMBS, args as memoryblock) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a double return value.

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)

JavaClassMBS.CallStaticFloatMethod(MethodID as JavaMethodMBS, args as memoryblock) as single

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a float return value.

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)

JavaClassMBS.CallStaticIntMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with an integer return value.

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)

JavaClassMBS.CallStaticLongMethod(MethodID as JavaMethodMBS, args as memoryblock) as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 11.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a long return value.

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)

JavaClassMBS.CallStaticMain(args() as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static main method and passes the String array.

Some examples using this method:

JavaClassMBS.CallStaticMethod(MethodID as JavaMethodMBS, args() as Variant) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method.
Example
Var vm As JavaVMMBS // your initialized VM

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

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

// 2. lookup method
Var 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
Var param3() As Variant
param3.append "Hello World"
Call jclass.CallStaticMethod(jmethod3,param3)

MsgBox "done"

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.

JavaClassMBS.CallStaticObjectMethod(MethodID as JavaMethodMBS, args as memoryblock) as JavaObjectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with an object return value.
Example
Var e as JavaVMMBS // global

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

Var jclass, sclass as JavaClassMBS
Var jmethod as JavaMethodMBS
Var jstring as JavaStringMBS
Var args as JavaObjectArrayMBS
Var m as MemoryBlock
Var s as String
Var 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.Int64Value(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.Int64Value(0)=jstring.Handle

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

MsgBox jstring.CopyStringUTF
end if
end if
end if
end if

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)

Some examples using this method:

JavaClassMBS.CallStaticShortMethod(MethodID as JavaMethodMBS, args as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with a short return value.

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)

JavaClassMBS.CallStaticVoidMethod(MethodID as JavaMethodMBS, args as memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 4.3 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
Calls a static method with no return value.

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)

Some examples using this method:

JavaClassMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Java MBS Java Plugin 13.1 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
The private constructor.

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


The biggest plugin in space...