Maven error :Perhaps you are running on a JRE rather than a JDK?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I've never worked with Maven before and I am following the instructions here. When I run the command
mvn integration-test -Pamp-to-war
It initially downloaded a whole bunch of dependencies, and in the end it showed,
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
I am on ubuntu 13.04.
If there's anything you want me to tell you, let me know. Thanks.
EDIT
When I do echo $JAVA_HOME I get /usr/lib/jvm/java-7-openjdk-i386/
For me, it worked like following. Please look at JAVA_HOME environment variable, whether it is pointing to JRE or JDK.? If it pointed to JRE, you will face "Perhaps you are running on a JRE rather than a JDK" issue. if so change the path to JDK.
Modifying like this, it worked for me.
JAVA_HOME C:\Program Files\Java\jdk1.8.0_31
回答4:
This is how i fixed my problem
right clik on the project > properties > Java Compiler (select the one you are using)
it was 1.5 for me but i have 1.8 installed. so i changed it to 1.8.. and voilla it worked!.
Check if /usr/bin has 'javac'. If not you have installed JRE & have to install jdk dev version like "java-1.8.0-openjdk-devel.x86_64"
回答7:
Right click on your project folder (Maven one), select properties and from the properties window, again select Java Compiler and see what is selected against compiler compliance level and make sure that it is the same version as your jre. In my case I had 1.8 but 1.5 was selected against compiler compliance level. After selecting 1.8 the build was successful without this error.
回答8:
I had the same error and I was missing the User variable: JAVA_HOME and the value for the SDK - "C:\Program Files\Java\jdk-9.0.1" in my case
回答9:
Just adding more details on where to setup. Main reason would be the JAVA_HOME setup in the environment variable should be pointing to correct JDK location.
Edit "path" -> append %JAVA_HOME%; to the existing text.
回答10:
I had the same issue after installing the java-1.8.0-openjdk package on an AWS Linux AMI. The incorrect assumption I made, was that because the file ended in openjdk it would be the jdk version. This is not the case.
The java-1.8.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.8.0-openjdk-devel package.
If you've already installed the java-1.8.0-openjdk package, just leave it and the JAVA_HOME value if it's working for the JRE and install the java-1.8.0-openjdk-devel package using yum install java-1.8.0-openjdk-devel -y.