使用操作
使用前确认必须是server2008 64位系统 并且jdk是64位的,如果是32位的那么是不可以使用该jar的
1. j2v8_win32_x86_64-4.5.0.jar 中的dll取出并改名为j2v8_win32_x86_64.dll
2. 将j2v8_win32_x86_64.dll 放到jdk的jre的bin目录下
3. 以上完成既可以使用了
以下是一个简单的demo
System.out.println(1111); System.out.println("5jn9vc31snvjejkjgj7aiu6i".length()); V8 v8 = V8.createV8Runtime(); V8Array result = v8.executeArrayScript("var buffer = new ArrayBuffer(256);\n" + "var i32 = new Int32Array(buffer);\n" + "i32[0] = 1;\n" + "i32[1] = 3;\n" + "i32[2] = i32[0] + i32[1];\n" + "i32;"); int[] ints = result.getIntegers(0, 3); System.out.println("Result: " + ints[0] + ", " + ints[1] + ", " + ints[2]); result.release(); //v8.release(); v8.executeVoidScript("var abc =.........."); V8Array parameters = new V8Array(v8); parameters.push("xxxxxxxxxxxxxxxxxx"); String ssss = v8.executeStringFunction("abc", parameters); System.out.println(ssss); parameters.release(); v8.release();
原文地址:http://3876775.blog.51cto.com/3866775/1852398