Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java and Scala ClassNotFoundException after upgrading to IntelliJ 14

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

like image 459
BAR Avatar asked Dec 16 '14 06:12

BAR


People also ask

Does IntelliJ work with Scala?

To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.

How do I add Scala to global library in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.


1 Answers

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

like image 187
Michael Curtis Avatar answered Nov 15 '22 08:11

Michael Curtis