'Get pid of current Java process ; May not work on all JVM
' Tested: win 7 64bit ; ubuntu 14.04 lts 64bit ; mac os
'error -1
'http://www.golesny.de/p/code/javagetpid
Sub getPID As Int
Dim jo As JavaObject
jo.InitializeStatic("java.lang.management.ManagementFactory")
Dim pidstr As String = jo.RunMethodJO("getRuntimeMXBean",Null).RunMethod("getName",Null)
pidstr = pidstr.SubString2(0,pidstr.IndexOf("@"))
Dim pid As Int = -1
If IsNumber(pidstr) Then
pid = pidstr
End If
Return pid
End Sub