How to Import Package without SBT and Compile Multifile Projects?

Self-learning scala from Python and C++ background (but no JVM based language). Learnt the basic features of the language, but then I am seeing a lot of tutorials mix up concepts from SBT, to IDE specific stuffs (such as Intellij) to scala development itself while teaching.

Sorry, if the question is not organised, but how to basically import classes from other files (within my own project) without SBT? Do i need a very specific directory structure to be able to do that? Is there any tutorial anywhere that shows how to do it?

After that I would want to know how to use the exact same directory structure, but make it easier with SBT?

A general advice would be to stick to sbt or Mill. They both can have very minimalistic configuration if you don’t need to publish, compile across many target platforms nor have many dependencies.

However, to directly answer your question - you can try out Scala CLI. It allows to do what you want.

1 Like

Differently from Python, in Scala you can always access any type or value that are in the classpath.
The import statement just provides a short alias so you don’t need to specify the fully qualified name of the thing you want to access.

So no, you don’t need any specific project structure, you just need to properly refer to them and ensure they are in the classpath.
For the first thing, it does help to align your code structure with your package structure. For the second thing, using a build tool helps a lot since manually invoking the compiler and managing the classpath is really tedious and error-prone; and the moment you add third-party libraries it becomes a mess.