How do I import a Java package in Scala?

I have created a jar-file with a compiled Java class. Now I want to import it in Scala. But it doesn't work.

The package name is se.mydomain.testproj and here is a small Scala application:

object TestCrypt {

    import se.mydomain.testproj._

    def main(args: Array[String]) {
      println("Hello")
    }
}

I use Eclipse and have added the jar file to the Build Path.

In Eclipse, I get the error: not found: value se

How can I import Java classes from a Jar file in Scala?

Answers


I do this all the time in Eclipse, so it definitely works. Do you see the jar in the Referenced Libraries of the project? Do you have the package name right?

Also, an import in the object as opposed to the top of the file should be fine.


Need Your Help

Is .NET MailMessage class injection-safe?

.net email

I wonder if MailMessage class is protected from e-mail injection. For example, should I check values before passing them to its constructor:

Can I embed nearly any font in my Windows application, provided it's only installed during execution of the application?

windows winapi fonts

Most fonts provided with Windows + Office have at least a "Print & Preview embedding allowed" status.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.