6

I recently upgraded to IntelliJ 14, then added Scala support.

My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:

Exception in thread "main" java.lang.ClassNotFoundException: GUI

It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.

I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.

It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.

This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
BAR
  • 15,909
  • 27
  • 97
  • 185
  • Where is that error coming from? Is it your own GUI file? – Makoto Dec 16 '14 at 07:03
  • Its a skeleton FX hello world that has no other project deps, and no errors. Works in main module, but not if it is in any other. – BAR Dec 16 '14 at 07:04

3 Answers3

24

Sample View of the problem Sample View of the problem

I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.

Solution

Solution Image

lakshman
  • 2,641
  • 6
  • 37
  • 63
Michael Curtis
  • 564
  • 3
  • 9
0

Turns out that Make, No Error Check does not work the same for scala as it does for Java.

Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.

Fixing the scala files fixes the error.

BAR
  • 15,909
  • 27
  • 97
  • 185
0

In my case, the solution was at the JDK and java level. When I set JDK 14 this error occurred.

So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.

  1. In project(module) settings section: Project, Modules, SDK's

  2. In main method settings: JRE

S.Daineko
  • 1,790
  • 1
  • 20
  • 29