Cannot resolve method java ошибка

What are common causes for IntelliJ IDEA not being able to resolve built-in JVM types and methods? For example, when I mouse over String the tooltip says "Cannot resolve symbol 'String'". It's as if

What are common causes for IntelliJ IDEA not being able to resolve built-in JVM types and methods? For example, when I mouse over String the tooltip says «Cannot resolve symbol ‘String'». It’s as if IntelliJ has doesn’t know where the JVM is.

By the way, I am running OS X 10.6.6. Everything was working fine until I ran the system update this morning.

Cœur's user avatar

Cœur

36.4k25 gold badges191 silver badges258 bronze badges

asked Jan 6, 2011 at 19:13

Landon Kuhn's user avatar

Landon KuhnLandon Kuhn

75k43 gold badges103 silver badges130 bronze badges

2

Most likely JDK configuration is not valid, try to remove and add the JDK again as I’ve described in the related question here.

Community's user avatar

answered Jan 6, 2011 at 19:20

CrazyCoder's user avatar

CrazyCoderCrazyCoder

382k168 gold badges965 silver badges882 bronze badges

1

First check if you have configured JDK correctly:

  • Go to File->Project Structure -> SDKs
  • your JDK home path should be something like this:
    /Library/Java/JavaVirtualMachine/jdk.1.7.0_79.jdk/Contents/Home
  • Hit Apply and then OK

Secondly check if you have provided in path in Library’s section

  • Go to File->Project Structure -> Libraries
  • Hit the + button
  • Add the path to your src folder
  • Hit Apply and then OK

This should fix the problem

answered Sep 28, 2015 at 3:03

user4660857's user avatar

3

I was facing the same problem when import projects into IntelliJ.

for in my case first, check SDK details and check you have configured JDK correctly or not.

Go to File-> Project Structure-> platform Settings-> SDKs

Check your JDK is correct or not.

enter image description here

Next, I Removed project from IntelliJ and delete all IntelliJ and IDE related files and folder from the project folder (.idea, .settings, .classpath, dependency-reduced-pom). Also, delete the target folder and re-import the project.

The above solution worked in my case.

answered Aug 21, 2020 at 5:24

Maulik Kakadiya's user avatar

Maulik KakadiyaMaulik Kakadiya

1,3951 gold badge19 silver badges30 bronze badges

1

For me, I had to remove the intellij internal sdk and started to use my local sdk. When I started to use the internal, the error was gone.

my sdks

answered Feb 27, 2021 at 21:19

Thiago Cavalcanti's user avatar

I tried almost everything but nothing was helping with the ibm jdk 1.8. to fix this issue. then I found an article from https://youtrack.jetbrains.com/issue/IDEA-279214/Cannot-resolve-symbol-String-when-using-IBM-JDK-180 and it worked like charm!!!

so sharing original help credit goes to @Serge Barano. incase anybody needs and not able to able to resolve the issue using previous solutions like me.

according to the article answer is:

IBM JDK has a weird layout and the jar with the String class is in bin directory for some reason:

d:devibm_sdk80jrebindefaultjclSC180vm.jar

If you add it to the JDK classpath in IntelliJ IDEA, the issue should resolve:
enter image description here

answered Jun 1, 2022 at 19:56

Priyanka Wagh's user avatar

For me, IntelliJ could autocomplete packages, but never seemed to admit there were actual classes at any level of the hierarchy. Neither re-choosing the SDK nor re-creating the project seemed to fix it.

What did fix it was to delete the per-user IDEA directory ( in my case ~/.IntelliJIdea2017.1/) which meant losing all my other customizations… But at least it made the issue go away.

answered Jul 6, 2017 at 2:03

Darien's user avatar

DarienDarien

3,40218 silver badges35 bronze badges

First of all you should try File | Invalidate Caches and if it doesn’t help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

answered Aug 12, 2021 at 11:16

sarjeet singh's user avatar

For me ,

File -> project structure -> Project Language Level (11) selection worked. Local variable syntax for lambda paramters.

answered Oct 18, 2021 at 9:42

Rishabh Dugar's user avatar

In my case, cloning repo from the remote was the easiest way to solve this issue.

answered Apr 27, 2022 at 18:14

Temur Isroilov's user avatar

cannot resolve method ‘getParameter(java.lang.String)’

Вы столкнулись с этой проблемой?

Изначально использовал Myeclipse, позже перешел на IDEA, различные проблемы не решаются, эта проблема одна из них.

У него также есть проблема с братом:

cannot resolve method ‘println(java.lang.String)’

Рисунок выше — это скриншот кода после решения.

Решение:

1. Очистите кеш

Нажмите «Файл» в верхнем левом углу —-> «Недействительные кеши / перезагрузка».

В появившемся диалоговом окне нажмите «Invalidate».

Если этот метод не работает, обратитесь ко второму способу.

2. Добавьте кота

Нажмите «Файл» в верхнем левом углу ——> Структура проекта

В новом диалоговом окне нажмите «Модули» —-> «+» —-> «Библиотека или зависимость модуля ..»

Появится диалоговое окно, выберите кот ——> нажмите «Добавить выбранное».

Нажмите «Применить» —-> «ОК»

3. Альтернативный метод

Если вы не можете решить эту проблему, попробуйте вернуться к методу 1: «Файл» —-> «Недействительный кеш / перезапуск» —-> во всплывающем диалоговом окне нажмите «Недействительность и перезапуск».

Хорошо, на данный момент моя проблема решена.

заметка:

Операционная система: win7

JDK:1.6

tomcat:1.7

Браузер: Charm

Инструмент программирования: IDEA

Срок решения: два дня

Решение: сначала устраните проблему, чтобы найти причину, а затем слепо измените ее и продолжайте попытки и ошибки. В то же время браузер ищет похожие проблемы и, наконец, решает их.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Comments

@oleksandrzaiats

After fix for #778 issue I have got an error in IDE.
I am using new version of lombok with the fix (1.16.16) and Java 8.
It turns whole my project to red with hint that IDE Cannot resolve method 'onMethod_' (I am using Intellij).
But compilation is successful and generated code is working as expected.

public class DTO {
	@Getter(onMethod_= @TestAnnotation(testParam = "testParam"))
	@Setter
	String data;
}

Actually there is not such method in sources https://github.com/rzwitserloot/lombok/blob/master/src/core/lombok/Getter.java, only AnyAnnotation[] onMethod() default {};
I don’t want to disable Cannot resolve method Intellij inspection, is there any way to fix it?

@ikstewa

@Maaartinus

Actually there is not such method in sources

AFAIK, it mustn’t exist.

https://projectlombok.org/features/experimental/onX.html

The syntax is a little strange and depends on the javac you are using.
On javac7, to use any of the 3 onX features, you must wrap the annotations to be applied to the constructor / method / parameter in @__(@AnnotationGoesHere)….
On javac8 and up, you add an underscore after onMethod, onParam, or onConstructor.

@denbypda

Getting the same issue when using new Java8 onMethod syntax with Windows jdk1.8.0_121 and lombok 1.16.16.

Using the new JDK 8 syntax

@Getter(onMethod_ = { @JsonProperty(value = ID) })

No IDE, just javac

error: cannot find symbol
@getter(onMethod_ = { @JsonProperty(value = ID) })
^
symbol: method onMethod_()
location: @interface Getter

@vguna

Same here, exact same version.

@evgenyh

facing the same
any solution for this ?

@roglar

I run into this when upgrading to java8 but not another person in my team!
After comparison we found out that compiler arg caused this (in maven)

javac -processor org.checkerframework.checker.nullness.NullnessChecker …

Without this even the java7 method compiles, will delombok getters and setters that needed this…

@LilithBristol

Same here

JDK:9.0.4
idea: 2018.1
lombok:1.16.20

can some one help?

@ronnyfm

Facing a similar issue when I run Enunciate plugin. Eclipse works after I run the Lombok JAR, and the Maven project compiles without errors, but other IDEs (like Visual Studio Code) and moreover, the Enunciate plugin is unable to finish.

@ronnyfm

I run into this when upgrading to java8 but not another person in my team!
After comparison we found out that compiler arg caused this (in maven)

javac -processor org.checkerframework.checker.nullness.NullnessChecker …

Without this even the java7 method compiles, will delombok getters and setters that needed this…

Do you mean to add that parameter or to remove it in order to compile? I was trying to add the parameter in the Maven configuration but it is not working.

@oleksandrzaiats

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Cannot recover after last error any further errors will be ignored перевод
  • Cannot receive hello packet miflash ошибка edl
  • Cannot receive hello packet miflash как исправить
  • Cannot read property url of undefined ошибка wink как исправить
  • Cannot read property match of undefined как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии