Link to home
Start Free TrialLog in
Avatar of ank5
ank5Flag for India

asked on

Code not compiling in eclipse

I am trying to set up an existing project in eclipse. After creating the project, when I open any of the source files, it gives me errors like

the type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

Can someone please let me know what settngs do I need to make to have it compiled with Java. Java is already set is the Path environment variable of the system. I am able to execute Java commands from command prompt. Do I need to do something in eclispe as well?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ank5

ASKER

>>check if you have JRE_SYSTEM_LIBRARY in build path.

No it is not there. How do I add it?
Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')

Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project

see link above
Go to properties of project with the build error (right click > Properties)

View the "Libraries" tab in the "Build Path" section

Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project)

Remove the "JRE System Library"

Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')

Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project

Hopefully the error will be resolved ...