gpt4 book ai didi

scala - 无法使用 :cp command 将 jar 添加到 Scala repl

转载 作者:行者123 更新时间:2023-12-04 08:35:40 24 4
gpt4 key购买 nike

如果我发出:

$ scala -classpath poi-3.9/poi-3.9-20121203.jar 

scala> import org.apache.poi.hssf.usermodel.HSSFSheet
import org.apache.poi.hssf.usermodel.HSSFSheet

一切正常,但如果我发出:
$ scala

scala> :cp poi-3.9/poi-3.9-20121203.jar
Added '/home/sas/tmp/poi/poi-3.9/poi-3.9-20121203.jar'. Your new classpath is:
".:/home/sas/tmp/poi/poi-3.9/poi-3.9-20121203.jar"
Nothing to replay.

scala> import org.apache.poi.hssf.usermodel.HSSFSheet
<console>:7: error: object apache is not a member of package org
import org.apache.poi.hssf.usermodel.HSSFSheet
^

我错过了什么吗?

最佳答案

似乎没有人提到这一点,但正确的解决方案是使用 :require command :

scala> :require foo.jar
Added 'foo.jar' to classpath.

关于scala - 无法使用 :cp command 将 jar 添加到 Scala repl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18033752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com