1

I got to work with an existing java code base which uses gradle. I had to create a new class and import it in an existing class. When I run gradle build or gradle bootRun it gives the following error and build fails.

error: cannot find symbol

import com.someservice.generic.model.SomeNewClass;

                                ^   

symbol: class SomeNewClass

location: package com.someservice.generic.model

Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileJava'.

    Compilation failed; see the compiler error output for details.

My new class looks like as follow,

package com.someservice.generic.model;

public class SomeNewClass {


}

And I import it as

import com.someservice.generic.model.RUnregPatient;

I have referred following questions

Getting "cannot find Symbol" in Java project in Intellij

Can't compile java class in Intellij Idea due to "cannot find symbol class X" error

and tried reimporting, invalidatite cache and restarting, rebuilding as suggested. None of them worked for me.

Achala Dissanayake
  • 810
  • 3
  • 16
  • 33
  • On IntelliJ, go to File -> Settings -> Project Settings -> Compiler -> Java Compiler, and on the right-hand side, for Additional command line parameters enter "-Xlint:unchecked". After that, compile again and paste the error in your post – Villat Oct 16 '19 at 04:09
  • @Villat thanks for the comment. Somehow when I deleted the class file and created a new one it worked. – Achala Dissanayake Oct 16 '19 at 04:17

1 Answers1

1

Deleting the new class file and creating another one solved the issue somehow.

Achala Dissanayake
  • 810
  • 3
  • 16
  • 33
  • 1
    I had a similar experience and it's solved by moving the class to a different package and then moving it back. – Loran Dec 21 '22 at 04:16