static void Main(string[] args) { // Create Java Runtime using (JavaRuntime jre = new JavaRuntime()) { // Load Java Virtual Machine jre.Load(); // This is equal with -> String myValue = System.getProperty("java.version") // Splitted if for easier debugging. JClass javaType = jre.GetClass("java.lang.System"); // Invokes static method "getProperty" with parameter "java.version" which returns "java.lang.String" and casts it to generic parameter "string". string javaVersion = javaType.InvokeStaticMethod<string>("getProperty", "java.lang.String", "java.version"); Console.WriteLine($"Currently used Java version: { javaVersion }"); } }
/// <summary> /// Adds archive to runtime. /// </summary> /// <param name="pathOrName"></param> public void AddArchive(string pathOrName) { JClass javaClass = this.Gateway.LoadClass("java.lang.System"); javaClass.InvokeStaticMethod <object>("loadLibrary", "V", pathOrName); }