Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling a hibernate app

 
John Cronk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

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?

thanks!
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems your compiler level is not set to 5.0 or higher.

In eclipse select your project and

Click on Project-->Properties-->Java Compiler and check if Compliance level is set to 5.0 or higher.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
John Cronk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your answers

I'm sure it is the JDK and I think it's the environment settings. Please can you answer this dumb question about jdk's...

I have three folders on this PC under program files/java:
j2re1.4.2_15
jdk1.5.0_12
jre1.6.0

I set my "java_home" setting to the jre1.6.0 folder. Is this the same thing as the jdk, or is the jre something different??

Whichever one it is, which particular settings should I then check aside from java_home?

thanks!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JRE (Java Runtime Environment) is the JDK (Java Development Kit) without the compiler and other tools you need to develop Java software.

The JRE is only for running Java programs (what a normal end-user needs), the JDK is for software developers who want to write their own Java programs.

If you're using Eclipse, then make sure the compiler settings in Eclipse are set to Java 5 (see the suggestions above).
 
John Cronk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ug I'm still missing something:

JAVA_HOME = C:\Program Files\Java\jdk1.5.0_12
The project compiler compliance level is 5.0

Yet on running my ant build I get:


I've restarted once or twice, JAVA_HOME is definitely 1.5 as stated above. Why does Eclipse state this variable as jre1.6.0?

Other bits of info:
Eclipse Preferences > Java > Compiler > Installed JREs
is set for jre 1.6.0

There is an environment variable called CLASSPATH which is set to:
CLASSPATH = .;C:\Program Files\Java\jre1.6.0\lib\ext\QTJava.zip

Any ideas guys?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Cronk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

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 ?
 
Suraj Berwal
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Kind Regards,
Suraj
 
John Cronk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right that's sorted - it was indeed the config settings

Thanks to everyone who replied!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic