• Scala on Visual Studio Code


    [comment]: # Scala on Visual Studio Code

    Download and install Scala

    Download a scala installation package from here.
    Then install it.

    • Linux
    scala_package_name=$(ls scala*.tgz | sort -r | head -1)
    tar -xzf $scala_package_name
    mv ${scala_package_name%.*} scala
    

    Configure system variables:

    • Linux
    export SCALA_HOME=/opt/scala
    PATH=%PATH%:$SCALA_HOME/bin
    
    • Windows
    SCALA_HOME=C:Program Files (x86)scala
    PATH=%SCALA_HOME%in;%PATH%
    

    Test

    scala
    
    • Output:
    Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
    Type in expressions for evaluation. Or try :help.
    
    scala>
    

    Configur a project in visual studio code

    • Open a project via File -> Open Folder...
    • Create a tasks.json file under the .vscode folder in the project folder.
    • Input below in the task.json file
    // A task runner that runs a scala program
    {
        "version": "0.1.0",
        "isShellCommand": true,
        "args": [],
        "showOutput": "always",
        "echoCommand": true,
        "suppressTaskName": true,
        "windows": {
            "command": "cmd",
            "args": [
                "/C",
                "scala.bat"
            ]
        },
        "linux": {
            "command": "sh",
            "args": [
                "scala"
            ]
        },
        "osx": {
            "command": "sh",
            "args": [
                "scala"
            ]
        },
        "tasks": [
            {
                "taskName": "run",
                "isBuildCommand": true,
                "args": [
                    "${file}"
                ]
            }
        ]
    }
    

    Note: I am using Windows, you need to change scala.bat to scala (I guess).

    Linux

    Test it

    • Create a file test.scala with code
    object HelloWorld {
      def main(args: Array[String]): Unit = {
        println("Hello, world!")
      }
    }
    
    • press ctrl+shift+b
    • Output:
    Hello, world!
    

    Compile .scala to .jar

    scalac -d test.jar D:project*
    
  • 相关阅读:
    视图类、二次封装、视图家族、GenericAPIView视图基类、mixins视图6大工具类、generic中的工具视图、路由组件
    单改、整体/局部修改、群改接口
    多表、序列化反序列化、群增单删群删接口
    解析模块
    drf框架
    vue-04
    vue-03
    VUE-02
    vue
    ❥《python入门到入土》全教程❥
  • 原文地址:https://www.cnblogs.com/steven-yang/p/5852988.html
Copyright © 2020-2023  润新知