aspose file tools*
The moose likes Beginning Java and the fly likes Compiling a hibernate app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling a hibernate app" Watch "Compiling a hibernate app" New topic
Author

Compiling a hibernate app

John Cronk
Greenhorn

Joined: Mar 07, 2008
Posts: 7
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

Joined: May 18, 2007
Posts: 341

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

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
John Cronk
Greenhorn

Joined: Mar 07, 2008
Posts: 7
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

Joined: Aug 16, 2005
Posts: 13875
    
  10

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).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
John Cronk
Greenhorn

Joined: Mar 07, 2008
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Mar 07, 2008
Posts: 7
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

Joined: Dec 28, 2001
Posts: 26
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

Joined: Mar 07, 2008
Posts: 7
Right that's sorted - it was indeed the config settings

Thanks to everyone who replied!
 
Consider Paul's rocket mass heater.
 
subject: Compiling a hibernate app
 
Similar Threads
unable to create War using Ant
Compilation Error while using Hibernate Annotations
Error running javac.exe compiler
JAVA 1.5 and ANT gives : java.util.zip.ZipException: error in opening zip file
say what?