Scala on Visual Studio Code
2016-09-08 14:40
651 查看
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:
Linuxexport SCALA_HOME=/opt/scala PATH=%PATH%:$SCALA_HOME/bin
Windows
SCALA_HOME=C:\Program Files (x86)\scala PATH=%SCALA_HOME%\bin;%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 codeobject 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\*
相关文章推荐
- CodeRush for Visual Studio .NET v.3.0.1 (Beta) released on 4 Dec 2007
- CodeRush for Visual Studio .NET v.3.0.1 (Beta) released on 4 Dec 2007
- How To Install Visual Studio Code On Ubuntu
- How to debug .NET Core RC2 app with Visual Studio Code on Windows?
- Safe! Repel Attacks on Your Code with the Visual Studio 2005 Safe C and C++ Libraries
- Apache Cordova development lands on Visual Studio Code
- How to debug test code on Windows Mobile Emulator with Visual Studio
- Getting started with aspnet5 and visualstudio code on a mac or linux
- [乐意黎原创]Node.js 出现Error:Cannot find runtime 'node' on PATH - Visual Studio Code中的解决办法
- C# on Visual Studio Code
- First ASP.NET Core Application on a Mac Using Visual Studio Code
- 打造TypeScript的Visual Studio Code开发环境
- visual studio code for mac 的对齐快捷键
- vscode: Visual Studio Code 常用快捷键
- Pasting nicely formatted code into your blog from Visual Studio.NET
- visual studio code教程
- Visual Studio Code使用typings拓展自动补全功能
- Visual Studio Code更改语言
- 借助Visual Studio Code提高基于ActionScript的LayaAir HTML5游戏的调试效率
- Step by Step Setup Git Server on Windows with CopSSH + msysGit and Integrate Git with Visual Studio