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.

Читайте также:  Half life 2 episode 3 дата выхода

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 link a Core Java class (Format) that has worked well
for me for years. In the same project, I have a routine that makes a
call:
Format.print(os, "%5.4f
", fVar);
I get a msg from the JBuilder compiler:
Cannot resolve symbol: variable Format in class.
The thing is, in the same project I have a routine that makes the exact same call successfully! Why does this one file not able to make the proper link to the Format class?? I have tried copying the successful routine into a dummy routine and trying to compile it and still it won’t link. Any ideas?

    4 Contributors

  • forum4 Replies 206 Views 3 Days Discussion Span
  • commentLatest Post 14 Years Ago by gracin
Читайте также:  Amd radeon hd 6500 series характеристики

I am trying to link a Core Java class (Format) that has worked well
for me for years. In the same project, I have a routine that makes a
call:
Format.print(os, "%5.4f
", fVar);
I get a msg from the JBuilder compiler:
Cannot resolve symbol: variable Format in class.
The thing is, in the same project I have a routine that makes the exact same call successfully! Why does this one file not able to make the proper link to the Format class?? I have tried copying the successful routine into a dummy routine and trying to compile it and still it won’t link. Any ideas?

hi
I can’t understand ur problem unless I see ur code.

Is the Format class file in the same directory as the file you are not able to compile?
If it is not, are you importing the package?

Is your print() method in the Format package static?

You say that you can make the call "successfully" in another part of the project. Please elaborate on what you mean by "successfully". Do you mean that you can compile one class in the project which uses that code but no other classes? Or do you mean that the IDE doesn’t indicate that there are any issues?

You really must give more information if we are to help you. Provide the basic structure of your Format class (including its package declaration and the print method definition), provide a more detailed view of the class that you are trying to compile (what it imports and where in the class you are trying to call the Format method), and provide details about the class that successfully compiles (assuming that there is one).

Читайте также:  Nescafe dolce gusto krups инструкция по применению

And please. Put all your code inside CODE tags.

yah, Format is in java.text, you probably forgot to import it.

The Format class IS in the same directory as the file I am trying to link with. I am not importing the package.
The print() method is not static. I am posting the Format class call (I am not using a part of Java, it is code from the Core Java book).

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *