cannot resolve symbol java

I installed Intellij 6.0.5 on a new machine, and I’m getting this error on all my classes:

Cannot resolve symbol ‘java’

And all the java packages aren’t recognized (‘java’ is shown in red for import java.util).

I have jdk 1.4.2, 1.5 and 1.6 installed, each one set up in intellij, and I get the same problem when I choose them for the project. If I choose the Intellij IDEA SDK for for the JDK, then things work.

Any ideas why the others don’t work? When I look at the JDK dialog, it looks like it has the classpath, sourcepath and javadoc paths all set up properly (same as my other laptop, which works fine).

I’m not sure what else to try. any suggestions?

Thanks in advance.

Votes

Share

Just in case anyone else is having the same problem, I uninstalled all the JDK’s / JRE’s on my system, and then installed jdk 1.5. Even though it’s the same jdk that Intellij was pointing to before, it fixed the problem when the others weren’t installed on the machine.

I had the same problem moving from Windows XP to Ubuntu. I must have had C:Program FilesSunJavablahblah set in some file or something. I went into:

File
Project Structure
under Platform Settings
JDKs

I deleted the old JDK object and made a new one pointed to /usr/lib/jvm/java-6-sun/ instead. That did it!

Thanks for your post! It helped me narrow down the problem and lowered my blood pressure at the same time.

This is if you see Java classes in red and get this error, «Cannot resolve symbol».

If you’re importing projects into IntelliJ and none of the above solutions worked for you then give this a try. This is what worked for me when everything else failed.

Go to to your project folder and rename/delete the .idea folder which has the idea settings for your project. This would have been created from your old IntelliJ version. Once you have renamed/deleted the .idea folder, import your project into IntelliJ. You should not see any errors for your Java classes now. Hope this helped.

In my case I imported the Intellij settings from a different PC and the java path is pointing to a older version(which is not present). So I just changed the java build path while setting up the project, that worked for me.

Я создал класс «Мой», в котором я просто беру данные от пользователя, используя класс «Сканер»,

Но я получаю следующие ошибки:

Вы создали объект Scanner качестве scanner , поэтому измените sc на scanner . Код будет компилироваться без каких-либо проблем.

Кроме того, еще один момент, вместо использования ниже кода

Вы можете напрямую использовать Scanner sc = new Scanner(System.in) так как вы уже импортировали класс Scanner

Примечание. Используйте java1.5 и выше для доступа к классу сканера

I am trying to use the javamail program (with a few modifications). I am getting a cannot resolve symbol for the senDatMail method that I am using.
I’m not a proficent java programmer so I’m not sure why i am getting the error but my troubleshooting has lead me to the sendDatMail(args); line in my code that is causing the error.

I have spent many hours trying to get this code to work so any help would be greatly appreciated.

You’ve put the sendDatMail() method into a separate class, which means that you can’t call it from the main code of the JSP without referencing an instance of that class. THe easy fix would be simply to remove the «public class sendDatMail <" line, and the matchine closing brace; that should fix the compile error you're seeing.

Now, I have to point something out: as you’re already no doubt aware, JSPs with huge tracts of Java code are ugly and very hard to work with. Modern practice is to put the vast majority of your code into separate Java classes, then reference those classes from the JSP, using as little embedded Java code as possible.

Оцените статью