Maven cannot find tools.jar w/ proper JAVA_HOME - windows

I am having some trouble building a Maven project on my Windows machine. I have set my JAVA_HOME environment variable and Maven finds it.
Here are come results from a few executions:
'which mvn'
/cygdrive/c/Program Files/Apache/apache-maven-3.0.5/bin/mvn
'mvn -version'
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28 0800)
Maven home: C:\Program Files\Apache\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"
Note: It does find the proper JAVA_HOME path here!
Building w/ Maven:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
0.2:compile (default-compile) on project sportbukkit-api: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre6\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
As you can see, for some reason it is looking in the completely wrong directory. Please let me know if any more info is needed or if you know how to fix this! Thank you!

Try setting your JAVA_HOME to C:\Program Files\Java\jdk1.6.0_45 instead of C:\Program Files\Java\jdk1.6.0_45\jre

Related

Maven Build failure in Jenkins

While running a build in Jenkins Maven is complaining about JDK. I know very well that it's some challenge with env variables. I have set JAVA_HOME to JDK installation path but no luck. I have searched the whole web and know that other people have faced this but their solution isn't working for me. Any help would be really appreciated !
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
FYR, my maven version output.
root#zarvis:~# mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /usr/local/apache-maven-3.3.3
Java version: 1.7.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-31-generic", arch: "amd64", family: "unix"
JAVA_HOME is set but not sure why maven appends it with JRE.
root#zarvis:~# echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-amd64
Thanks in advance !
Try adding JDK_HOME to your path

Build HikariCP from source

I want to replace BoneCP with HikariPC. Downloaded tar.gz from here and extracted. I don't know if this is a right command but inside hikaricp-java6 directory I run
$ mvn clean compile assembly:single
maven prints error
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/gkiko/Downloads/brettwooldridge-HikariCP-5cb1000/hikaricp-java6/src/main/java/com/zaxxer/hikari/util/ConcurrentBag.java:[358,20] cannot find symbol
symbol : method hasQueuedPredecessors()
location: class com.zaxxer.hikari.util.ConcurrentBag.Synchronizer
[ERROR] /Users/gkiko/Downloads/brettwooldridge-HikariCP-5cb1000/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/HikariPool.java:[150,37] cannot find symbol
symbol : method setRemoveOnCancelPolicy(boolean)
location: class java.util.concurrent.ScheduledThreadPoolExecutor
[ERROR] /Users/gkiko/Downloads/brettwooldridge-HikariCP-5cb1000/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/HikariPool.java:[486,28] cannot find symbol
symbol : method abort(java.util.concurrent.ExecutorService)
location: interface com.zaxxer.hikari.proxy.IHikariConnectionProxy
[INFO] 3 errors
[INFO] ------------------------------------------
[INFO] -------------------------------------------------------
[INFO] BUILD FAILURE
maven version:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T21:37:52+04:00)
Maven home: /usr/local/Cellar/maven/3.2.1/libexec
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
java version:
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
Could you please tell me how to get jar file of HikariCP so I can add it to my java web app and use it with sqlite?
Java 8 is required to build HikariCP -- even the Java 6/7 compatible version. But you can download the JAR from the maven central repository here:
http://search.maven.org/#search%7Cga%7C1%7Chikaricp
Click on the 'jar' link for the HikariCP-java6 version 2.0.1 entry (second line).

No valid Maven installation found

I have a maven project with JavaServerFaces name in intellij . whan I want to run(clean&package) it I encounter with this error:
Error running JavaServerFaces [clean,package]: No valid Maven installation found. Either set the home directory in the configuration dialog or set the M2_HOME environment variable on your system.
but I sure that my maven installation is correct and when check it in cmd I get this massage:
cmd: mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 17:21:
28+0330)
Maven home: J:\maven\apache-maven-3.0.5\bin\..
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
my MAVEN_HOME:
J:\maven\apache-maven-3.0.5
path: %MAVEN_HOME%\bin
what is problem? please help me. thanks
Change name of MAVEN_HOME variable to M2_HOME or M3_HOME depending on Maven version.

Maven & JDK 1.7 on Mac

When I try to compile a project with Maven I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
My JAVA_HOME is pointing to the JDK:
$ echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
$ $JAVA_HOME/bin/javac -version
javac 1.7.0_25
javac: no source files
Usage: javac <options> <source files>
I'm not sure why Maven adds '/jre' to the end of JAVA_HOME, but looking at some other posts this doesn't seem to be the problem:
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000)
Maven home: /Users/jerry/dev/springsource/apache-maven-3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
I've searched for a solution to this problem and tried different things for the last couple of days, but can't find anything that works. I've seen some threads with a similar problem, but none of the suggestions worked for me.
Does anyone know how to solve this? Any help greatly appreciated...
You should assign the real path to the JDK to the JAVA_HOME variable instead of leaving the CurrentJDK literal. For some reason in Mac OS X the CurrentJDK is not pointing to the actual one regarding Maven. Try something like this in your .profile but replacing you actual jdk folder name:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
FYI, one cause of "no source files" is lack of disk space wherever tmp points.
Looks like maven and javac store some items in TEMP/TMP/TMDIR and if that director doesn't exist, lacks space, lacks permissions then you can see that problem. at least we did on windows and I suspect it'll happen on better operating systems too.

Netty compile error

I can't compile netty anymore. mvn compile gives the following:
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # netty-common ---
[INFO] Compiling 60 source files to /home/dennis/git/netty4/common/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
/opt/java/jre1.6.0_30/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
My configuration:
export JAVA_HOME=/opt/java/jre1.6.0_30
export M2_HOME=/opt/apache-maven-3.0.3
export M2=$M2_HOME/bin
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$M2:$PATH
A part of my path:
$echo $PATH
/opt/java/jre1.6.0_30/bin:/opt/apache-maven-3.0.3/bin:/opt/git/bin:[...]
Maven status:
dennis#denpc:~/git/netty4$ mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /opt/apache-maven-3.0.3
Java version: 1.6.0_30, vendor: Sun Microsystems Inc.
Java home: /opt/java/jre1.6.0_30
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "2.6.24-30-generic", arch: "i386", family: "unix"
Any ideas?
Please ensure you are using JDK 1.4 or above and
not a JRE [...]
It might have to do with this line in the error given in your post above. I believe you might want to make sure that you have the path to your JDK set, as well. Otherwise, it's just finding the JRE (jre1.6.0_30).
Note: The JDK might be found in your Java SDK folder.

Resources