File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes error occured in maven compilation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "error occured in maven compilation" Watch "error occured in maven compilation" New topic

error occured in maven compilation

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I'm using maven to compile a sample project, and I got this error:

package javax.annotation does not exist

I googled it and people says it's not using the correct Java version, it should use java 5, or later.
Then I checked my machine:

-bash-3.2$ javac -version
javac 1.6.0-internal

-bash-3.2$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.5.0_16
Java home: /usr/java/jdk1.5.0_16/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.18-164.15.1.el5" arch: "i386" Family: "unix"

It looks like I'm using the correct Java version. Why maven is still complain about it?


Peter Johnson

Joined: May 14, 2008
Posts: 5850

Looks like you have two different Java installations. What do you have JAVA_HOME set to? Try running:

$JAVA_HOME/bin/java -version

I suspect that you 1.6 version is not a valid version, I certainly do not recognize the output from "javac -version".

Also, using 1.5 is not sufficient - it does not include the javax.annotation package.

My suggestion would be to install JDK 1.6 from Sun (or I guess it is Oracle now) and set JAVA_HOME to reference that. Then run mvn again.

JBoss In Action
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
thanks for the reply, I reinstalled jdk with 1.6, now its compiling.
I agree. Here's the link:
subject: error occured in maven compilation