'Azure Synapse - How do I define a (Scala) utility class that I can use in other notebooks?

I'm migrating from Databricks to Azure Synapse. In Databricks, I have a couple utility classes that are defined in notebooks that start with:

package myUtilityNamespace

object myUtilityClass {...code...}

And then where I want to use that utility class I have a cell that runs the notebook that defines the utility class like:

%run ../myNotebookThatDefinesUtilityClass

Followed by a cell that imports the namespace:

import myUtilityNamespace

And then in subsequent cells I can use myUtilityClass.

How do I do the same thing in Azure Synapse? I feel dumb asking this question... how do I create a class???

When I try the same thing in Azure Synapse Studio I get this error in my console output:

error: illegal start of definition
       package myUtilityNamespace;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source