Platforms to show: All Mac Windows Linux Cross-Platform
/Java/Java Set System Property
Required plugins for this example: MBS Java Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Java/Java Set System Property
This example is the version from Tue, 6th Mar 2023.
Project "Java Set System Property.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open()
#If TargetMacOS Then
// change the path for your installation!
JavaVMMBS.SetLibraryPath("/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/lib/server/libjvm.dylib")
#ElseIf TargetLinux Then
// change path for your linux PC!
JavaVMMBS.SetLibraryPath("/home/cs/jre1.6.0_05/lib/i386/client/libjvm.so")
#EndIf
dim options() as string
dim javaVm as new JavaVMMBS(JavaVMMBS.JNI_VERSION_1_4, options, true)
Dim system As JavaClassMBS = javaVm.FindClass("java/lang/System")
dim transfomerSetPropertyId as JavaMethodMBS = system.GetStaticMethod("setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;")
dim transfomerGetPropertyId as JavaMethodMBS = system.GetStaticMethod("getProperty", "(Ljava/lang/String;)Ljava/lang/String;")
Dim keyString As JavaStringMBS = javaVm.NewStringUTF8("javax.xml.transform.TransformerFactory")
Dim valueString As JavaStringMBS = javaVm.NewStringUTF8("net.sf.saxon.TransformerFactoryImpl")
Dim m As MemoryBlock = New MemoryBlock(16)
m.Int64Value(0)=keyString.Handle
m.Int64Value(8)=valueString.Handle
dim o as JavaObjectMBS = system.CallStaticObjectMethod(transfomerSetPropertyId, m)
m = New MemoryBlock(8)
m.Int64Value(0)=keyString.Handle
dim r as JavaObjectMBS = system.CallStaticObjectMethod(transfomerGetPropertyId, m)
if r<>Nil then
dim s as JavaStringMBS = JavaStringMBS(r)
MsgBox s.CopyStringUTF
end if
End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
See also:
The items on this page are in the following plugins: MBS Java Plugin.