-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/31/2014 8:49 AM, Ole Ersoy wrote: > Hi, > > I'm seeing some strange behavior with Maven 3.0.5 on Ubuntu. > > BACKGROUND ===================== When I run `mvn test` the console > prints: `[ERROR] No compiler is provided in this environment. > Perhaps you are running on a JRE rather than a JDK?` > > If I then open the project in Eclipse and run the test it runs > fine. Subsequently if I close Eclipse and run the test with `mvn > test` I get `BUILD SUCCESS`. > > ANALYSIS ===================== I run `mvn test` on the `test2` > project, that was opened with eclipse, and I get -> `BUILD > SUCCESS`. > > I then create a `test3` project, copy the pom and the src directory > from test2 to test 3. When running `mvn test` on the `test3` > project I get the error again. I included the result from my > console below: > > ole@MKI:~/test2$ mvn test Warning: JAVA_HOME environment variable > is not set. [INFO] Scanning for projects... [INFO] [INFO] > ------------------------------------------------------------------------ > > [INFO] Building test-maven 1.0.0 > [INFO] > ------------------------------------------------------------------------ > > [INFO] > [INFO] --- maven-resources-plugin:2.3:resources (default-resources) > @ test-maven --- [WARNING] Using platform encoding (UTF-8 actually) > to copy filtered resources, i.e. build is platform dependent! > [INFO] skip non existing resourceDirectory > /home/ole/test2/src/main/resources [INFO] [INFO] --- > maven-compiler-plugin:3.2:compile (default-compile) @ test-maven > --- [INFO] No sources to compile [INFO] [INFO] --- > maven-resources-plugin:2.3:testResources (default-testResources) @ > test-maven --- [WARNING] Using platform encoding (UTF-8 actually) > to copy filtered resources, i.e. build is platform dependent! > [INFO] skip non existing resourceDirectory > /home/ole/test2/src/test/resources [INFO] [INFO] --- > maven-compiler-plugin:3.2:testCompile (default-testCompile) @ > test-maven --- [INFO] Nothing to compile - all classes are up to > date [INFO] [INFO] --- maven-surefire-plugin:2.10:test > (default-test) @ test-maven --- [INFO] Surefire report directory: > /home/ole/test2/target/surefire-reports > > ------------------------------------------------------- T E S T S > ------------------------------------------------------- Running > hello.HelloUnitTest Greeting from hello the Unit Test! Tests run: > 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec > > Results : > > Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > > [INFO] > ------------------------------------------------------------------------ > > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > > [INFO] Total time: 1.027s > [INFO] Finished at: Wed Dec 31 10:41:25 CST 2014 [INFO] Final > Memory: 8M/240M [INFO] > ------------------------------------------------------------------------ > > ole@MKI:~/test2$ mkdir ../test3 > ole@MKI:~/test2$ cp pom.xml ../test3 ole@MKI:~/test2$ cp -r src > ../test3 ole@MKI:~/test2$ cd ../test3/ ole@MKI:~/test3$ mvn test > Warning: JAVA_HOME environment variable is not set. [INFO] Scanning > for projects... [INFO] [INFO] > ------------------------------------------------------------------------ > > [INFO] Building test-maven 1.0.0 > [INFO] > ------------------------------------------------------------------------ > > [INFO] > [INFO] --- maven-resources-plugin:2.3:resources (default-resources) > @ test-maven --- [WARNING] Using platform encoding (UTF-8 actually) > to copy filtered resources, i.e. build is platform dependent! > [INFO] skip non existing resourceDirectory > /home/ole/test3/src/main/resources [INFO] [INFO] --- > maven-compiler-plugin:3.2:compile (default-compile) @ test-maven > --- [INFO] No sources to compile [INFO] [INFO] --- > maven-resources-plugin:2.3:testResources (default-testResources) @ > test-maven --- [WARNING] Using platform encoding (UTF-8 actually) > to copy filtered resources, i.e. build is platform dependent! > [INFO] skip non existing resourceDirectory > /home/ole/test3/src/test/resources [INFO] [INFO] --- > maven-compiler-plugin:3.2:testCompile (default-testCompile) @ > test-maven --- [INFO] Changes detected - recompiling the module! > [WARNING] File encoding has not been set, using platform encoding > UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source > file to /home/ole/test3/target/test-classes [INFO] > ------------------------------------------------------------- > [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 [INFO] > ------------------------------------------------------------- > [INFO] > ------------------------------------------------------------------------ > > [INFO] BUILD FAILURE > [INFO] > ------------------------------------------------------------------------ > > [INFO] Total time: 0.722s > [INFO] Finished at: Wed Dec 31 10:42:07 CST 2014 [INFO] Final > Memory: 8M/303M [INFO] > ------------------------------------------------------------------------ > > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-compiler-plugin:3.2:testCompile > (default-testCompile) on project test-maven: Compilation failure > [ERROR] No compiler is provided in this environment. Perhaps you > are running on a JRE rather than a JDK? [ERROR] -> [Help 1] > [ERROR] [ERROR] To see the full stack trace of the errors, re-run > Maven with the -e switch. [ERROR] Re-run Maven using the -X switch > to enable full debug logging. [ERROR] [ERROR] For more information > about the errors and possible solutions, please read the following > articles: [ERROR] [Help 1] > http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException > > ole@MKI:~/test3$ tree . ├── pom.xml ├── src │ └── test │ > └── java │ └── hello │ └── > HelloUnitTest.java └── target ├── generated-test-sources │ └── > test-annotations ├── maven-status │ └── maven-compiler-plugin │ > └── testCompile │ └── default-testCompile │ > ├── createdFiles.lst │ └── inputFiles.lst └── > test-classes > > 12 directories, 4 files > > Thoughts (Besides just open it in Eclipse :) )? > > TIA, - Ole
Eclipse comes with its own compiler, so it only needs the JRE to run. The command line needs the JDK, which you don't have installed. Install the JDK, set $JAVA_HOME, and make sure $JAVA_HOME/bin is on your path. See the bottom of the following page for detailed instructions: http://maven.apache.org/download.cgi If you're uncomfortable about using a different Java version between command line and Eclipse, you can always point Eclipse to the JRE inside the JDK and use that as the default JRE for Eclipse and the IDE. . . . just my two cents /mde/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJUpC/HAAoJEEFGbsYNeTwtO2kIAKEr2DC7OZt2hNMDhpuXtPqF /XtQHTMRR6W0SFXXkCDe4tqa2mGpQLSNUjXYUoDyw9QqX0YiS/X4kZwsPZOSjvrV fyYccm48U1/njdS6yiWbeuDqVSHGvWfrf7vv1L+/j28YhI8ZxM9PaXXJ05iBECmW t88hDHHNJpewf9IkIED5EHyFhie+pLqh+nITtLdrKx70zUwr6nVVXDglfbUbAuMK LueQ8hGWeQdpaj98zo0BnJYpi2bIRQ7inLNOthRDgSBZkcRVWHln4Gv05UFt/vhP en924SAlSRrSenKub7HhWzI0GaGnSGSyf1TRY75za6zgSNWbGVieb36pFyoqYd4= =BFis -----END PGP SIGNATURE----- --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org