Is there a way to import packages from your current project into a worksheet
Asked Answered
J

1

9

I like worksheets as an alternative to the REPL, but I keep implementing functions in the worksheet and then copying them back into the actual project. How do I import a package from the current project so that I can call those functions in the worksheet?

Japan answered 1/10, 2012 at 4:32 Comment(2)
No, i tried the obvious, but overlooked a separate obvious mistake -- my worksheet was in a different project ( i had two worksheets and was using the wrong one, duuh)Japan
Answer wasn't obvious to me either. The "._" bit escaped me.Rebatement
A
9

There is nothing special to do. Just do regular import of the packages you need in the worksheet. For instance:

import com.acme.myproject._

The worksheet is a totally regular source file, that simply gets evaluated in a fancy manner on save.

Alecalecia answered 1/10, 2012 at 7:8 Comment(2)
This is not working for me. I keep getting a notFound type error, however y I press Command and click on the class the Class opens, so on one hand it seems to "know" which class im refering to, and on the other it just wont run because the Class is not foundCosset
same problem here - my not-yet-published package com.myCompany.myPackage. If I want to use: import com.myCompany.myPackage.MyPackage: object myPackage is not a member of package com.myCompanyDatnow

© 2022 - 2024 — McMap. All rights reserved.