Coder Social home page Coder Social logo

hybird's Introduction

安装GraalVM

安装GraalVM很简单,相当于新增一个JDK

GraalVM官网的快速开始页面提供了4种不同系统的安装方式

  • Linux
  • macOS
  • Windows
  • Docker Container 这里选择macOS安装方式,没有提供dmg安装方式,需要在Github下载压缩包

https://github.com/graalvm/graalvm-ce-builds/releases

下载后用tar命令解压,移动到/Library/Java/JavaVirtualMachines目录下(需要sudo)

sudo tar -xzf graalvm-ce-java<version>-darwin-aarch64-<version>.tar.gz
 
sudo mv graalvm-ce-java<version>-<version> /Library/Java/JavaVirtualMachines

在IDEA中配置GraalVM

在IntelliJ IDEA 2022.3 (Ultimate Edition)中新建项目hybrid,并添加GraalVM到JDK

代码测试

新建一个controller,添加一个接口,返回一个字符串

体验多语言特性

执行结果如下

示例代码

@RestController
@RequestMapping("/hybrid")
public class HybirdController {

    @GetMapping("/hello")
    public String hello() {

        // Java代码作为启动代码
        System.out.println("Hello GraalVM! from Java");
        System.out.println("Let's go with JavaScript");

        Context polyglot = Context.create();
        polyglot.eval("js", "print('Hello GraalVM! from JavaScript')");
        return "hello";
    }
}

hybird's People

Contributors

everettsy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.