J2V8: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 39: Line 39:
* [https://stackoverflow.com/questions/6369919/ How to embed V8 in a Java]
* [https://stackoverflow.com/questions/6369919/ How to embed V8 in a Java]
* [https://eclipsesource.com/blogs/tutorials/getting-started-with-j2v8/ Getting Started With J2V8]
* [https://eclipsesource.com/blogs/tutorials/getting-started-with-j2v8/ Getting Started With J2V8]
* [https://github.com/eclipsesource/J2V8/blob/master/src/main/java/com/eclipsesource/v8/utils/V8ObjectUtils.java V8ObjectUtils]
* [https://github.com/eclipsesource/j2v8 Building J2V8]
* [https://github.com/eclipsesource/j2v8 Building J2V8]
* [https://github.com/alicorn-systems/v8-adapter V8 Adapter]

Revision as of 17:45, 28 February 2021

package com.example;

import com.eclipsesource.v8.V8;

public class EclipseCon_snippet5 {

    public static class Printer {
        public void print(String string) {
            System.out.println(string);
        }
    }

    public static void main(String[] args) {
        V8 v8 = V8.createV8Runtime();
        v8.registerJavaMethod(new Printer(), "print", "print", new Class<?>[]{String.class});
        v8.executeVoidScript( "print('Hello, World!');" );
        v8.release(true);
    }
}
<dependencies>
    <dependency>
        <groupId>com.eclipsesource.j2v8</groupId>
        <artifactId>j2v8_macosx_x86_64</artifactId>
        <version>2.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>


References