I'm attempting to compile a java application that uses hibernate. On compilation I get the following error:
So java isn't recognising the "@" character as valid. I was told that this might be from using java 4 or earlier, but Eclipse is currently set to use jre1.6.0. Can anyone suggest why these characters aren't recognised?
There is only one reason: you are not using the JDK you thing you are. Double check your eclipse settings, it need to be a version greated than or equal to 1.5 to use Annotations. [ March 10, 2008: Message edited by: Paul Sturrock ]
Environment variables don't come into it. In eclipse right click on your project and got to "Java Build Path". Make sure the JRE System Library (Libraries tab) is pointing to a "JRE" that is at least 1.5 (eclipse does a confusing thing here - it calls them JREs, but you need to point it at a JDK). Also check your Java Compiler settings. The Compiler compliance setting needs to be 5.0.
Originally posted by John Cronk: Ok I compared my settings with another person's PC here, and they were using JRE 1.5.
So I downloaded that and changed my eclipse JRE settings to point to this instead.
You are not required to use JRE but JDK. Eclipse internally refers JDK as JRE.
Originally posted by John Cronk:
Now on ant build I get
So it appears that Eclipse's understanding of what JAVA_HOME is has been affected by my changing the default JRE.
JAVA_HOME is definitely "C:\Program Files\Java\jdk1.5.0_12"
?? Again, any ideas anyone ?
This was bound to happen.
Now please execute the following steps to resolve your problem: 1) Goto Window --> Preferences --> Java --> Installed JREs 2) Select the Installed JRE displayed in the list which will be pointing to "C:\Program Files\Java\jre1.5.0_15" and Click on Edit 3) In the EditJRE window click on Browse button and select the location as "C:\Program Files\Java\jdk1.5.0_12". 4) Click on OK for each window and try to run you program again. 5) Your program should work now.