javaintellij-ideajar

easy way to add jar dependencies to a scratch file in intelij


I have created a scratch file scratch.java

I added a new plain java module that contains the following:

enter image description here

I have specified the dependency in the build configuration for the scratch file:

The dependencies are not found when I try and edit and build the scratch file.
How can I easily add dependencies to a scratch file in intelij?

enter image description here


Solution

  • In the Run/Debug Configuration... setting, you can make your scratch file run using a specific classpath or module. Just change Use classpath of module or Program arguments.