简体   繁体   English

Scala,jar文件的问题

[英]Scala, problem with a jar file

I haven't worked with java/scala a lot, so my problem might be very obvious, but here it is: 我没有经常使用java / scala,所以我的问题可能非常明显,但这里是:

I'm working on a scala program, and I want to import from a .jar file (filename.jar) in a sub-directory. 我正在研究scala程序,我想从子目录中的.jar文件(filename.jar)导入。 I figure that this will work: 我认为这将有效:

import sub.filename._

But I get the error: "Object filename is not a member of package sub." 但我得到错误:“对象文件名不是包子的成员。”

So I try simply moving the jar file to the same directory as the scala program: 所以我尝试将jar文件移动到与scala程序相同的目录:

import filename._

And I get: "not found: object filename" 我得到:“找不到:对象文件名”

I'd appreciate any help. 我很感激任何帮助。

That doesn't work. 这不起作用。 You import things from packages, not directories. 您从包中导入东西,而不是目录。 If you have a JAR somewhere, you need to start Scala with the classpath parameter pointing to all JARs you want access to. 如果某处有JAR,则需要使用指向要访问的所有JAR的classpath参数启动Scala。

ok, so i am going to change my comment into an answer: 好的,所以我要将我的评论改为答案:

add the jar file to your classpath :) 将jar文件添加到classpath :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM