Ubuntu下安装Scala
前言
弄了一下终于成功装上了,这里对此进行一下总结
安装虚拟机
VMware虚拟机安装Ubuntu(超详细图文教程)_vmware安装ubuntu-CSDN博客https://blog.csdn.net/qq_43374681/article/details/129248167Download Ubuntu Desktop | Download | Ubuntu
https://ubuntu.com/download/desktop安装redhat虚拟机_怎么安装redhat的虚拟机-CSDN博客
https://blog.csdn.net/weixin_64066303/article/details/130287039?spm=1001.2014.3001.5501有了前面安装红帽的经验,我相信Ubuntu的安装是得心应手了。
安装Java
Ubuntu下安装Java_ubuntu安装java-CSDN博客https://blog.csdn.net/JqlScala/article/details/133462691直接可以指令安装
更新所有软件包
sudo apt update
安装默认Java运行时环境(JRE)
sudo apt install default-jre
安装Java开发工具包(JDK)
sudo apt install default-jdk
验证是否安装成功
root@feng-virtual-machine:~# java -version
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1, mixed mode, sharing)
安装Scala
All Available Versions | The Scala Programming Language (scala-lang.org)https://www.scala-lang.org/download/all.html(Spark)学习进度十五(虚拟机(ubuntu)安装scala和使用) - 细胞何 - 博客园 (cnblogs.com)
https://www.cnblogs.com/hwh000/p/12310651.html
然后按照他的步骤,解压和配置环境。
添加(/usr/local/scala是自己的安装路径)
export SCALA_HOME=/usr/local/scala
export PATH=${SCALA_HOME}/bin:$PATH
使环境变量生效
source /etc/profile
root@feng-virtual-machine:~# scala -version
Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL
但是结果出现了
root@feng-virtual-machine:/usr/local/scala# ./bin/scala
Exception in thread "main" java.lang.NoClassDefFoundError: javax/script/Compilableat scala.tools.nsc.interpreter.ILoop.createInterpreter(ILoop.scala:118)at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:911)at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:909)at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
./bin/scala出错(Exception in thread “main“java. lang . NoClassDefFoundError: javax/script/Compilable)_exception in thread "main" java.lang.noclassdeffou-CSDN博客https://blog.csdn.net/weixin_52350007/article/details/120569898推测是版本不兼容的问题,然后我找到了一个选择版本的
JDK Compatibility | Scala Documentation (scala-lang.org)https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
因为JDK显示是11,之后我安装了2.11.12版本的Scala还是失败了,然后安装3.0.0的没有明显的下载文件,只有一个GitHub的地址。
所以我选择下载2.13.0的版本。
按照同样的方法结果又可以了。
root@feng-virtual-machine:/usr/local/scala/bin# scala
Welcome to Scala 2.13.0 (OpenJDK 64-Bit Server VM, Java 11.0.22).
Type in expressions for evaluation. Or try :help.scala> println("Hello World!")
Hello World!scala>
虽然是出现了一个警告,但是还是可以运行。
root@feng-virtual-machine:~# cd /usr/local/scala
root@feng-virtual-machine:/usr/local/scala# sudo mkdir mycode
root@feng-virtual-machine:/usr/local/scala# cd ./mycode
root@feng-virtual-machine:/usr/local/scala/mycode# ls
root@feng-virtual-machine:/usr/local/scala/mycode# sudo vim HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# ls
HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# scalac HelloWorld.scala
warning: there was one deprecation warning (since 2.13.0); re-run with -deprecation for details
one warning found
root@feng-virtual-machine:/usr/local/scala/mycode# ls
'HelloWorld$.class' HelloWorld.class HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# scala -classpath . HelloWorld
Hello World!
root@feng-virtual-machine:/usr/local/scala/mycode# ls
'HelloWorld$.class' HelloWorld.class HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# cat HelloWorld.scalaobject HelloWorld{def main(args: Array[String]){println("Hello World!")}
}
root@feng-virtual-machine:/usr/local/scala/mycode#
按要求加上deprecation参数,显示该语法被弃用了。
root@feng-virtual-machine:/usr/local/scala/mycode# scalac -deprecation HelloWorld.scala
HelloWorld.scala:3: warning: procedure syntax is deprecated: instead, add `: Unit =` to explicitly declare `main`'s return typedef main(args: Array[String]){^
one warning found
按照要求修改之后就可以了,添加` :Unit=`
root@feng-virtual-machine:/usr/local/scala/mycode# scalac HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# cat HelloWorld.scala
object HelloWorld{def main(args: Array[String]): Unit={println("Hello World!")}
}
root@feng-virtual-machine:/usr/local/scala/mycode# ls
'HelloWorld$.class' HelloWorld.class HelloWorld.scala
root@feng-virtual-machine:/usr/local/scala/mycode# scala -classpath . HelloWorld
Hello World!
root@feng-virtual-machine:/usr/local/scala/mycode#
FinalShell
FinalShell官网 (hostbuf.com)https://www.hostbuf.com/这里还有一个软件,感兴趣的小伙伴可以尝试一下,在windows系统下连接Linux的虚拟机。
其中“名称”是自己起,“主机”是用ifconfig指令查看,“端口”默认是22,认证是root,密码就是root的密码。密码不知道可以设置一下。
【ubuntu】设置root用户密码_ubuntu设置root用户密码-CSDN博客https://blog.csdn.net/weixin_43500200/article/details/131118075我的是inet 192.168.92.130
root@feng-virtual-machine:~# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.92.130 netmask 255.255.255.0 broadcast 192.168.92.255inet6 fe80::5c97:a5d8:e86f:ce76 prefixlen 64 scopeid 0x20<link>ether 00:0c:29:5f:3c:62 txqueuelen 1000 (以太网)RX packets 279948 bytes 161217845 (161.2 MB)RX errors 42 dropped 42 overruns 0 frame 0TX packets 385434 bytes 102925217 (102.9 MB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0device interrupt 19 base 0x2000 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (本地环回)RX packets 7077 bytes 854481 (854.4 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 7077 bytes 854481 (854.4 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
当然输入密码的时候,密码不会回显。
root@feng-virtual-machine:~# sudo passwd root
新的密码:
重新输入新的密码:
passwd:已成功更新密码
root@feng-virtual-machine:~#
补:
决定还是安装新版的Scala,JDK还是17,Scala选择了3.3.3.
Java Downloads | Oraclehttps://www.oracle.com/java/technologies/downloads/#java17
# sudo dpkg -i jdk-17_linux-x64_bin.deb
# java -versionjava version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)
root@feng-virtual-machine:~#
然后使用了Scala,结果报错了。
scala> println("hello world")
java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URIat java.base/jdk.internal.jrtfs.JrtPath.toUri(JrtPath.java:175)at scala.tools.nsc.classpath.JrtClassPath.asURLs(DirectoryClassPath.scala:216)at scala.tools.nsc.classpath.AggregateClassPath.$anonfun$asURLs$1(AggregateClassPath.scala:63)at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)at scala.collection.immutable.Vector.flatMap(Vector.scala:113)at scala.tools.nsc.classpath.AggregateClassPath.asURLs(AggregateClassPath.scala:63)at scala.tools.nsc.interpreter.IMain.compilerClasspath(IMain.scala:93)at scala.tools.nsc.interpreter.IMain.makeClassLoader(IMain.scala:352)at scala.tools.nsc.interpreter.IMain.ensureClassLoader(IMain.scala:275)at scala.tools.nsc.interpreter.IMain.classLoader(IMain.scala:278)at scala.tools.nsc.interpreter.IMain.runtimeMirror$lzycompute(IMain.scala:168)at scala.tools.nsc.interpreter.IMain.runtimeMirror(IMain.scala:168)at scala.tools.nsc.interpreter.IMain.$anonfun$getModuleIfDefined$1(IMain.scala:177)at scala.tools.nsc.interpreter.IMain.getModuleIfDefined(IMain.scala:170)at scala.tools.nsc.interpreter.IMain.readRootPath(IMain.scala:289)at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.resolvePathToSymbol(IMain.scala:662)at scala.tools.nsc.interpreter.IMain$Request.resultSymbol$lzycompute(IMain.scala:919)at scala.tools.nsc.interpreter.IMain$Request.resultSymbol(IMain.scala:918)at scala.tools.nsc.interpreter.IMain$Request.typeOf$lzycompute(IMain.scala:930)at scala.tools.nsc.interpreter.IMain$Request.typeOf(IMain.scala:935)at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:897)at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:493)at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:487)at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:470)at scala.tools.nsc.interpreter.shell.ILoop.interpretStartingWith(ILoop.scala:930)at scala.tools.nsc.interpreter.shell.ILoop.command(ILoop.scala:787)at scala.tools.nsc.interpreter.shell.ILoop.processLine(ILoop.scala:462)at scala.tools.nsc.interpreter.shell.ILoop.loop(ILoop.scala:485)at scala.tools.nsc.interpreter.shell.ILoop.run(ILoop.scala:1019)at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:87)at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:91)at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:102)at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:107)at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.RuntimeException: /packages cannot be represented as URI... 35 moreThat entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]
于是按照前面的要求下载的3.3.3版本的Scala。
Release 3.3.3 · lampepfl/dotty (github.com)https://github.com/lampepfl/dotty/releases/tag/3.3.3
# sudo tar -zxvf scala3-3.3.3.tar.gz -C /usr/local
# scala -version
Scala code runner version 3.3.3 -- Copyright 2002-2024, LAMP/EPFL
scala> println("hello world")
hello world
相关文章:

Ubuntu下安装Scala
前言 弄了一下终于成功装上了,这里对此进行一下总结 安装虚拟机 VMware虚拟机安装Ubuntu(超详细图文教程)_vmware安装ubuntu-CSDN博客https://blog.csdn.net/qq_43374681/article/details/129248167Download Ubuntu Desktop | Download | …...

无法启动报,To install it, you can run: npm install --save @/components/iFrame/index
运行的过程中后台报错 npm install --save /components/iFrame/index,以为是安装三方依赖错误,经过多次重装node_modules依然没有用。 没办法,只能在项目中搜索 components/iFrame/index这个文件。。突然醒悟。。。 有时候,犯迷…...

深入理解现代JavaScript:从语言特性到应用实践
💂 个人网站:【 海拥】【神级代码资源网站】【办公神器】🤟 基于Web端打造的:👉轻量化工具创作平台💅 想寻找共同学习交流的小伙伴,请点击【全栈技术交流群】 JavaScript作为一门动态、解释性脚本语言&…...

ThreadPoolExecutor 学习
ThreadPoolExecutor 是开发中最常用的线程池,今天来简单学习一下它的用法以及内部构造。 1、线程池存在的意义? 一般在jvm上,用户线程和操作系统内核线程是1:1的关系,也就是说,每次创建、销毁线程的时候&am…...
深入理解计算机操作系统书籍阅读感悟(一)
1.sp:表示为空格,ASCII为32 2.在我们写的每行程序结尾都有一个隐藏的\n(ASCII码值为10) 3.在书上的P2页上说:文本文件是指以ASCII码字符构成的文件,其余都是二进制文件 除了这种理解,更常见的…...

使用query请求数据出现500的报错
我在写项目的时候遇到了一个问题,就是在存商品id的时候我将它使用了JSON.stringify的格式转换了!!!于是便爆出了500这个错误!!! 我将JSON.stringify的格式去除之后,它就正常显示了&…...
PostgreSQL教程(二十一):服务器管理(三)之服务器设置和操作
本章讨论如何设置和运行数据库服务器,以及它与操作系统的交互。 一、PostgreSQL用户账户 和对外部世界可访问的任何服务器守护进程一样,我们也建议在一个独立的用户账户下运行PostgreSQL。这个用户账户应该只拥有被该服务器管理的数据,并且…...
Linux运维_Bash脚本_编译安装GNU-Tools
Linux运维_Bash脚本_编译安装GNU-Tools Bash (Bourne Again Shell) 是一个解释器,负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件,并于 1989 年发布的免费软件,作为 Sh (Bourne Shell) 的替代品。 您可以在 Linux 和 …...
leetcode 121.买卖股票的最佳时机
声明:以下仅代表个人想法,非官方答案或最优题解! 题目: 给定一个数组 prices ,它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格。 你只能选择 某一天 买入这只股票,并选择在 未来的某一个不同的…...

javaWebssh酒店客房管理系统myeclipse开发mysql数据库MVC模式java编程计算机网页设计
一、源码特点 java ssh酒店客房管理系统是一套完善的web设计系统(系统采用ssh框架进行设计开发),对理解JSP java编程开发语言有帮助,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。开发环境为TOMCAT7.0…...

vue3基础教程(2)——创建vue3+vite项目
博主个人微信小程序已经上线:【中二少年工具箱】。欢迎搜索试用 正文开始 专栏简介1. 前言2.node版本检测3.创建vue项目 专栏简介 本系列文章由浅入深,从基础知识到实战开发,非常适合入门同学。 零基础读者也能成功由本系列文章入门&#x…...
部署DNS 实战篇
二、DNS 部署 环境介绍 服务器3台、系统centos 安装软件 yum install -y bind bind-utils bind-chrootbind 主包bind-utils 客户端测试工具(host 、dig 、nslookup)bind-chroot chroot环境 禁锢dns服务器的工作目录caching-nameserver(rhel5提供…...

2023 2024年全国职业院校技能大赛中职组网络建设与运维赛项服务器Linux部分教程解析
欢迎合作 需要资料请私 Rocky 9 包含各种常考服务(包括新题型KVM等)...
Flask g对象和插件
四、Flask进阶 1. Flask插件 I. flask-caching 安装 pip install flask-caching初始化 from flask_cache import Cache cache Cache(config(CACHE_TYPE:"simple" )) cache.init_app(appapp)使用 在视图函数上添加缓存 blue.route("/") cache.cached(tim…...

26、Qt调用.py文件中的函数
一、开发环境 Qt5.12.0 Python3.7.8 64bit 二、使用 新建一个Qt项目,右击项目名称,选择“添加库” 选择“外部库”,点击“下一步” 点击“浏览”,选择Python安装目录下的libs文件夹中的“python37.lib”文件,点击“下…...

计算机网络实验一 网线制作
实验目的与要求: 实验目的 了解以太网网线(双绞线)和制作方法 实验内容 了解网线和水晶头 学习网线制作方法 实验环境和要求 网线 水晶头 压线钳 剥线钳 网线测试器 方法、步骤: 步骤一 准备工具和材料 步骤二 剥掉双绞线的外…...

android TextView 实现富文本显示
android TextView 实现富文本显示,实现抖音直播间公屏消息案例 使用: val tvContent: TextView helper.getView(R.id.tvContent)//自己根据UI业务要求,可以控制 图标显示 大小val levelLabel MyImgLabel( bitmap 自己业务上的bitmap )va…...

Linux常用命令(超详细)
一、基本命令 1.1 关机和重启 关机 shutdown -h now 立刻关机 shutdown -h 5 5分钟后关机 poweroff 立刻关机 重启 shutdown -r now 立刻重启 shutdown -r 5 5分钟后重启 reboot 立刻重启 1.2 帮助命令 –help命令 shutdown --help: ifconfig --help:查看…...
软考笔记--基于架构的软件开发方法
一.体系架构的设计方法概述 基于体系结构的软件设计方法ABSD是由体系结构驱动的,即指有构成体系结构的商业、质量和功能需求的组合驱动的。ABSD方法有3个基础。第1个基础是功能的分解。在功能分解中,ABSD方法使用已有的基于模块的内聚和耦合技术。第2个…...

CSS 盒子模型(box model)
概念 所有HTML元素可以看作盒子,在CSS中,"box model"这一术语是用来设计和布局时使用CSS盒模型本质上是一个盒子,封装周围的HTML元素,它包括:外边距(margin),边框(border),内边距(pad…...
Vue记事本应用实现教程
文章目录 1. 项目介绍2. 开发环境准备3. 设计应用界面4. 创建Vue实例和数据模型5. 实现记事本功能5.1 添加新记事项5.2 删除记事项5.3 清空所有记事 6. 添加样式7. 功能扩展:显示创建时间8. 功能扩展:记事项搜索9. 完整代码10. Vue知识点解析10.1 数据绑…...
解决本地部署 SmolVLM2 大语言模型运行 flash-attn 报错
出现的问题 安装 flash-attn 会一直卡在 build 那一步或者运行报错 解决办法 是因为你安装的 flash-attn 版本没有对应上,所以报错,到 https://github.com/Dao-AILab/flash-attention/releases 下载对应版本,cu、torch、cp 的版本一定要对…...
AI编程--插件对比分析:CodeRider、GitHub Copilot及其他
AI编程插件对比分析:CodeRider、GitHub Copilot及其他 随着人工智能技术的快速发展,AI编程插件已成为提升开发者生产力的重要工具。CodeRider和GitHub Copilot作为市场上的领先者,分别以其独特的特性和生态系统吸引了大量开发者。本文将从功…...

[免费]微信小程序问卷调查系统(SpringBoot后端+Vue管理端)【论文+源码+SQL脚本】
大家好,我是java1234_小锋老师,看到一个不错的微信小程序问卷调查系统(SpringBoot后端Vue管理端)【论文源码SQL脚本】,分享下哈。 项目视频演示 【免费】微信小程序问卷调查系统(SpringBoot后端Vue管理端) Java毕业设计_哔哩哔哩_bilibili 项…...

[大语言模型]在个人电脑上部署ollama 并进行管理,最后配置AI程序开发助手.
ollama官网: 下载 https://ollama.com/ 安装 查看可以使用的模型 https://ollama.com/search 例如 https://ollama.com/library/deepseek-r1/tags # deepseek-r1:7bollama pull deepseek-r1:7b改token数量为409622 16384 ollama命令说明 ollama serve #:…...

基于PHP的连锁酒店管理系统
有需要请加文章底部Q哦 可远程调试 基于PHP的连锁酒店管理系统 一 介绍 连锁酒店管理系统基于原生PHP开发,数据库mysql,前端bootstrap。系统角色分为用户和管理员。 技术栈 phpmysqlbootstrapphpstudyvscode 二 功能 用户 1 注册/登录/注销 2 个人中…...
Bean 作用域有哪些?如何答出技术深度?
导语: Spring 面试绕不开 Bean 的作用域问题,这是面试官考察候选人对 Spring 框架理解深度的常见方式。本文将围绕“Spring 中的 Bean 作用域”展开,结合典型面试题及实战场景,帮你厘清重点,打破模板式回答,…...

Scrapy-Redis分布式爬虫架构的可扩展性与容错性增强:基于微服务与容器化的解决方案
在大数据时代,海量数据的采集与处理成为企业和研究机构获取信息的关键环节。Scrapy-Redis作为一种经典的分布式爬虫架构,在处理大规模数据抓取任务时展现出强大的能力。然而,随着业务规模的不断扩大和数据抓取需求的日益复杂,传统…...

【C++】纯虚函数类外可以写实现吗?
1. 答案 先说答案,可以。 2.代码测试 .h头文件 #include <iostream> #include <string>// 抽象基类 class AbstractBase { public:AbstractBase() default;virtual ~AbstractBase() default; // 默认析构函数public:virtual int PureVirtualFunct…...

【大模型】RankRAG:基于大模型的上下文排序与检索增强生成的统一框架
文章目录 A 论文出处B 背景B.1 背景介绍B.2 问题提出B.3 创新点 C 模型结构C.1 指令微调阶段C.2 排名与生成的总和指令微调阶段C.3 RankRAG推理:检索-重排-生成 D 实验设计E 个人总结 A 论文出处 论文题目:RankRAG:Unifying Context Ranking…...