2

When I tried to Run a .java file during the build I got the following Error

Module 'JAVA-Workspace' production: java.lang.ClassCastException: class org.jetbrains.jps.builders.java.dependencyView.TypeRepr$PrimitiveType cannot be cast to class org.jetbrains.jps.builders.java.dependencyView.TypeRepr$ClassType (org.jetbrains.jps.builders.java.dependencyView.TypeRepr$PrimitiveType and org.jetbrains.jps.builders.java.dependencyView.TypeRepr$ClassType are in unnamed module of loader java.net.URLClassLoader @490d6c15)

'JAVA-Workspace' is my project directory. It was fine a few minutes ago I was debugging the same file. I did not install any new plugins at the time. Java 11 | Intellj Version

I tried :

  • Remove caches and indexes by Invalidate and Restart < Invalidate Caches < File.
  • Delete .idea in root directory of the project.

Thank You

7
  • 1
    Check if this helps: stackoverflow.com/questions/64336525/… Commented Feb 21, 2022 at 9:27
  • 1
    What version of Intellij, what version of java? Try also to run from command line and check the errors you obtain. I think the problem will be related with Java modules. See this: stackoverflow.com/questions/67782975/… Commented Feb 21, 2022 at 9:41
  • 1
    Have you tried creating a new project with just your source code to see if that builds? Or reinstalling IntelliJ? Commented Feb 21, 2022 at 10:49
  • 1
    @abhinit21 did you manage to find out what the issue was or how to fix it? Same thing happened to me, was working fine and suddenly this without any changes. Commented Sep 24, 2022 at 13:13
  • 1
    @Mr.O in my case I have deleted the build output folder "target" and then re-build the project solved the issue I have got help from -> intellj youtrack.jetbrains.com/issue/IDEA-289413/… Commented Sep 25, 2022 at 14:15

3 Answers 3

3

I have this problem recently. My solution is that find out the most possible file produce this error, such as the most recent edit file (such as xxx.java). The files have to be guessed. Copy a backup of the code and delete that file. Then try to compile again, (of course cancel or comment the other linkages to that file) until the project can be compiled. Then re-new the java files with same name and same code just deleted before. The project will be as same as before. Finally, it compiles normally.

Sign up to request clarification or add additional context in comments.

Comments

1

Just Build > Rebuild Project, worked fine

1 Comment

This answer does not add value as it is redundant to a pre-existing, more extensive answer.
0
  • Build-Rebuild Project.
  • File - Reload All from Disk.
  • Then that's done. Don't know why but it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.