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 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.9k25 gold badges193 silver badges262 bronze badges

asked Jan 6, 2011 at 19:13

Landon Kuhn's user avatar

Landon KuhnLandon Kuhn

75.9k45 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

387k170 gold badges980 silver badges896 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

4

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,4551 gold badge21 silver badges31 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

Priyanka WaghPriyanka Wagh

5951 gold badge7 silver badges17 bronze badges

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,45219 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

In my case, right click on String then choose «Show Context Actions», it will give you option to Setup JDK, then click always downloaded. Then the error will be gone.
enter image description here

answered May 4 at 2:06

Yibingqing Jiang's user avatar

Не могу понять почему не может реализовать метод

robotFirst.getName(), robotSecond.getName(),

метод getName не работает!

public static void doMove(AbstractRobot robotFirst, AbstractRobot robotSecond) {
        BodyPart attacked = robotFirst.attack();
        BodyPart defenced = robotFirst.defense();
        System.out.println(String.format("%s атаковал робота %s, атакована %s, защищена %s",
                robotFirst.getName(), robotSecond.getName(), attacked, defenced));
    }
}

Я так понимаю что мы обращаемся к объекту РОБОТУ (например robotFirst )и вызываем у него метод возвращения имени, но он почему то не работает.

Lombok is a library that reduces boilerplate code when using the Java programming language. In comparison with modern script languages such as Python or Ruby, Java tends to be overly verbose: In order to create a class with a few attributes serving as a data object, one needs to create numerous getters and setters as well as custom equals and hashCode implementations. Of course, the Java IDE landscape has reacted to this kind of problem a long time ago by equipping IDE users with several ways to generate these methods on demand.

However, maintaining such data classes can still be hassle: Just imagine a programmer quickly adding one or more attributes to a data class because a new feature needs to be implemented that relies on those. They surely will remember to generate the getters and setters because otherwise they won’t be able to access the new attributes. They might miss to update the toString method or the equals and hashCode methods, though, and what gives? All tests might pass and everything could be fine for a while. But then a bug is discovered that either might be related to the equals method not reflecting the newly added attributes that could potentially lead to overwriting data entities in collections or a crucial log message does not give a programmer the values of the added attributes because the toString method has not been updated.

Lombok deals with these problems by generating getters, setters, constructors, useful toString methods as well as equals and hashCode implementations in the build process of your app. Integrating Lombok, say, in a Gradle build, is as easy as adding

compileOnly 'org.projectlombok:lombok'

to the dependencies of your build.gradle file. Afterwards, a data class may be written as follows:

import lombok.*;

@Data
@NoArgsConstructor
@RequiredArgsConstructor
class Account {
  private @NonNull String accNumber;
  private double saldo;
}

The annotation @Data gives you getters and setters for all attributes of your class as well as a toString, a hashCode and an equals implementation. The annotations @NoArgsConstructor and @RequiredArgsConstructor give you the standard constructor as well as a constructor with all the required fields (in this case, all fields annotated as @NonNull).

Задача ‘Friends&Family’
В строке с методом nextDouble () и nextInt (), выдаёт ошибку…
5de65f093ef54905035008.jpeg

причём в разжовывании работы с сканером:
5de65f303bc69406092347.jpeg
всё работет норм.

Дело в — do?! Но нет! Я вставил пример из пояснения и он выдал ту же ошибку! У меня явно чего-то не хватает в идее!

*одно хорошо, пока курил, много интересного прочёл…
** работают jdk1.8.0_231 и java jre1.8.0_231

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

Have you ever encountered this problem?

Originally using Myeclipse, and later using IDEA, various problems can not be solved, this problem is one of them.

It also has a brother problem:

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

The above picture is a screenshot of the code after the solution.

Solution:

1. Empty the cache

Click «File»—->»Invalidate Caches / Restart» in the upper left corner

A dialog box pops up, click on «Invalidate».

If this method is not good, please see the second method.

2. Add tomcat

Click on «File» in the upper left corner——>Project Structure

In the new dialog box, click on «Modules»—->»+»—->»Library or Module Dependency..»

Pop up a dialog box, select tomcat——> click «Add Selected»

Click «Apply»—->»OK»

3, the alternate method

If it can’t be solved, try to return to Method 1: «File»—-> «Invalidate Caches / Restart»—-> pop-up dialog box, click «Invalidate and Restart».

OK, my problem has been solved at this time.

note:

Operating system: win7

JDK:1.6

tomcat:1.7

Browser: Charm

Programming tool: IDEA

Time to resolve: two days

Solution: First check the problem to find the cause, and then blindly modify the continuous trial and error, while the browser search for similar problems, and finally solve.

Возможно, вам также будет интересно:

  • Cannot read properties of undefined честный знак ошибка
  • Cannot read properties of undefined reading map ошибка
  • Cannot read properties of undefined reading length ошибка
  • Cannot read properties of null reading type еис ошибка
  • Cannot read properties of null reading classlist ошибка

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

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