fail in "mvn clean install"? - java

I am new in learning java programming! I want to make a .jar in a maven project. After running this command mvn clean install, I am getting the following error message:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile) on project wps-demo: Compilation failure
Unable to locate the Javac Compiler in:C:\Program Files\Java\jre7..\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
what can I do for clean this error!

It looks like you have only a JRE (Java Runtime Environment) installed, and not a JDK (Java Development Kit), as this error message says:
Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)
Download and install the JDK (not JRE) from Oracle's website.
The JRE allows you to run Java programs, but does not include the tools that you need to develop Java software, such as the Java compiler. The JDK does include those tools.
If you already have a JDK installed, then make sure that the JAVA_HOME environment variable refers to the directory where you have the JDK installed, and not to a directory with a JRE.

As your error says you have wrong value in JAVA_HOME variable in system settings... should be something like C:\Program Files\Java\jre6
You can find how to set it HERE for example.

You need to set the environment variable that specifies the location of your java development kit so that windows can find the Java libraries
Put java home path in a JAVA_HOME variable that you can create in the advanced tab of MyComputer properties.
The Java home path would look something like this
C:\Program Files\Java\jdk1.5
Hope this helps

You may also want to have a look at the following article from Maven http://maven.apache.org/guides/mini/guide-building-jdk14-on-jdk15.html
It states that from Maven 2.2.0, Java JDK 1.5 is needed to allow Maven to build the Java project. The article also goes on to show how some of these adjustments can be made so that JDK 1.5 or later can be used in the build process.

Related

java jre jdk setup using android bundled jre

There are many similar questions but mine is different so please read an entire question before nailing down the new.
Bundled JAVA jdk is automatically installed with Android Studio version 4.0.1. Everything I type java -version on my CMD then I get following message
C:\Users\OceanicBlue>java -version
'java' is not recognized as an internal or external command,
This is because JAVA_HOME is not setup so I tried following inside Environment Variables->System Variables in Windows 10 Machine but no luck. The problem is persistent.
JAVA_HOME -> C:\Program Files\Android\Android Studio\jre\
JAVA_HOME -> C:\Program Files\Android\Android Studio\jre\bin
JAVA_HOME -> C:\Program Files\Android\Android Studio\jre\jre\bin
JAVA_HOME -> %JAVA_HOME%\bin
Can I use Android's bundled JDK for JAVA_HOME? If not then which version should I download. Oracle forces you to register to use their JDK11. I refuse to give them my personal information to use something free. Also I don't want unnecessary extra versions of JAVA installed on my machine. Eventually they will cause problems.
What exactly am I trying to do? I am trying to compile Java programs using Command line. Android installed JDK for me so why not use it? No I am not able to compile a java project using the terminal screen inside Android Studio.
This is because JAVA_HOME is not setup
That's not what's happening. JAVA_HOME is not voodoo magic, the windows shell does not have some sort of built in knowledge. Commands entered are executed by scanning every entry in the PATH environment variable for java.exe, java.com, or java.bat. None are available. If you really want the java.exe found in C:\Program Files\Android\Android Studio\jre\bin to be used when you type 'java' on the command line (which will not magically make javac work at all, which is why I doubt this is actually want), then add that directory to the PATH variable. JAVA_HOME is mostly useless; a select few dated tools look at it sometimes and fail if it is not there; more modern tools may still look at it but also scan other places, such as the path or windows registry.
Furthermore, that's.. clearly not a bundled JDK, that's a bundled JRE, which can't be used for compiling. It does hava java.exe, but you can't use that to compile things. By nature of being a JRE, it is also obsolete/outdated (JREs are no longer part of how java is distributed; java8 is the last version with a JRE).
Note that javac in general is relatively useless when dealing with android; android does not run class files.
I am using Android Studio 4.1.1
What exactly am I trying to do? I am trying to compile Java programs using Command line. Android installed JDK for me so why not use it?
First of all, it is just the bundled JRE. Its is not JDK.
But, I was able to compile and run my test.java by adding two new entries in my environment variables.
C:\Program Files\Android\Android Studio\jre\jre\bin
C:\Program Files\Android\Android Studio\jre\bin
NB: I have never installed JDK before. I just used the JRE binaries present in jre/bin/ present within Android Studio folder
See the attached image.
I think you should recheck your environment variable or else try to get Android Studio latest release.

Cordova android run/build Error - Requirements check failed for JDK 1.8

I have built my cordova app and getting "Requirements check failed for JDK 1.8" error message.
Uninstalling all java and installing jdk 1.8 not solved my problem.
D:\xampp\htdocs\aware>cordova run android
Android Studio project detected
ANDROID_HOME=C:\Users\Baha\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_221
Requirements check failed for JDK 1.8
ScreenShots:
You might have installed more than one Java (binaries) on your system. First of all, check this, by executing where java command in your cmd.exe (command line).
Most likely, you will see more than one java.exe installed, and if so, this may be the reason, despite installing new Java, your system still provides one more other version of it;
Even if you have set your %JAVA_HOME% environment variable accordingly, there might be another java.exe available in your environment, either because of having some other Java binaries' bin folder added in the System variables' (under Environment Variables) Path variable, or because of having it at some other place, which is also available through any other environment variable (for instance: System32 on Windows).
Check where java and see your Path environment variable under the System Variables.
My problem solved partially, I have changed the path and try to build with vs code, it works, but phpstorm still not build my app.

Ant in Eclipse wants tools.jar but there's no tools.jar in Java 9/10

I'm trying to build a JavaFX application in e(fx)clipse using the build.fxbuild file. Unfortunately ant complains it can't find tools.jar. But tools.jar was removed starting from Java 9 (I'm actually using Java 10), so I can't add it to the ant classpath in Preferences > Ant > Runtime > Classpath. The actual error message on the console is this:
BUILD FAILED
<project_directory>\build\build.xml:59: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre-10.0.1"
My JAVA_HOME environment variable is also set to point to JDK 10, it's included in PATH as well, so I also don't understand the last line. What can I do in this situation?
TL;DR - update your Eclipse / e(fx)clipse installation.
According1 to this blog posting e(fx)clipse 3.0.0 supports Java 9. (Apparently a lot of changes were required to get rid of dependencies on Oracle implementation classes.)
The Eclipse project page for e(fx)clipse 3.0.0 says that:
it was released in June 2017
it is part of the Oxygen release(s)
There is no specific mention of releases supporting Java 10 or later (yet), but another blog post talks about how e(fx)clipse will have to cope with JavaFX11 being unbundled from the standard Java SE distributions.
1 - I am not in a position to validate this information ...
Are you using an older version of eclipse or is your JAVA_HOME incorrect?
First, download and use java 9 or 10 JDK.
Set your environment variable correctly (don't use JRE location),
Update your path to include the bin folder in your JDK folder
Make sure you have a recent version of eclipse

Unsupported Java Version: Cannot start under Java 1.7: Java 1.8 or later is required

I just updated to IntelliJ IDEA 16 which comes with Java JDK 1.8. Fyi, I had downloaded Java JDK 1.8 a long time ago.
I tried to run my plugin that I am developing, and I cannot even do that, I get the following error message (slightly condensed)
"C:\Program Files\Java\jdk1.7.0_45\bin\java" -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea "-Xbootclasspath/a:C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 144.3143.6\lib\boot.jar" -Didea.config.path=C:\Users\Christopher.IdeaIC14\system\plugins-sandbox\config - ... -Dfile.encoding=windows-1252 -classpath "C:\Program Files\Java\jdk1.7.0_45\lib\tools.jar; ... ;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 144.3143.6\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.intellij.idea.Main
Unsupported Java Version: Cannot start under Java 1.7.0_45-b18: Java 1.8 or later is required.
So, I clearly know what the problem is; however, I cannot seem to figure out where the location to fix this is.
I have tried a lot of things so far; most involve using the search box in Settings and switching whatever I could to version 1.8. Also, I had updated my Environment Variable for Java from 1.6 to 1.8
With all of these changes, nothing is working! So how do I go about fixing this seemingly simple issue?
Set IDEA_JDK (or IDEA_JDK_64) environment variable.
Check Selecting the JDK version the IDE will run under
TL;DR --> Set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_51
Java 8 is required to run IntelliJ IDEA starting from version 16 on all the supported platforms.
The actual JDK version used by the IDE can be verified in Help | About dialog (open any project to access the menu).
idea64.exe uses this JDK search in the following sequence:
IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
Under Arch Linux you can simply set java 8 as default (you must have it installed):
$ sudo archlinux-java set java-8-openjdk
In case anyone arrives here and hasn't had any luck with the other solutions, try this. I'm using PhpStorm under OSX, but the steps are probably applicable to JetBrains' other IDEs too:
Navigate to your IDE's config folder (see this article to learn how to find this folder's location).
Open the idea.propeties file.
If a JVMVersion attribute exists, delete that entire entry. If it doesn't exist, then this probably won't be of much help!
Save the file.
Launch your IDE.
Just set JAVA_HOME system variable to your JDK 8:
Run in cmd
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_111"
don't foget to change to your java path
In my case, Ubuntu 14 (32-bit), I opened the file:
/home/<user>/Programs/PhpStorm/bin/phpstorm.sh
and after
if [ "$JDK" = "" ] && [ "$OS_TYPE" = "Linux" ] && ........... fi
I added:
if [ "$JDK" = "" ]; then
JDK="/usr/lib/jvm/java-8-oracle"
fi
And then it works!
Double check that your JAVA_HOME points to the correct 1.8 Installation and make sure that in the PATH env there is no reference to "C:\Program Files\Java\jdk1.7.0_45\bin".
Try to print your JAVA_HOME/PATH from the Console and see what the output is. If your changes are not reflected logout and then login again.
IntelliJ 16 REQUIRES Java 8 to run, it won't run under Java 7. It's compiled to Java 8 classes so it can't ever be run on an older JVM.
This is well and clearly mentioned in the documentation.
So if you have your system JVM be an older one, it will fail to start unless you coerce it into using a non-default JVM.
Possibly you have some java related executables left over in your Windows/System32 directory, where some older Java installers would drop them. Delete these by hand from the file system and see what happens.
Just in case this page needs one more recommendation, I fixed the problem in my case by going to the IDE's config folder (as #Nate puts it, see here for how to locate it), and deleting the idea.jdk file (which held a reference to a 1.6 VM).
Apart from setting the correct Java version for the global, per project and per module SDK, for the Java Compiler, and for the language level, you also must set the Target bytecode version both for the project and (if you use maven) for each maven module.
Often the project bytecode version is correct but the module bytecode version is lower, i.e. 1.5.
The per-module bytecode version is not displayed when opening the default preferences via File > Other Settings > Default Settings. You must edit the current preferences either via a shortcut (i.e. ⌘+,) or from the main menu as shown below (for mac):
I had the same problem. All paths pointing to java jdk 8, but still throwing the error. I was able to run Android Studio by running the "studio64.exe" instead "studio.exe" in the bin folder

Java Compilation error Not able to configure JAVA_HOME

When i am running Jenkins which checks out code from a repository and perform mvn package or some command. I get this error:
Unable to locate the Javac Compiler in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../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.
My JAVA_HOME points at jdk location only.Still it looks at
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/tools.jar
for the compiler.Why is that???
It seems the problem is with the code ..It points to /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/ for the tools.jar,whereas it needs to look into the /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/lib/ where the jar is present.I tried copying the jar to jre /lib/ but to no avail.Any solutions for this...
Thanks for d answers anyway..
You need jdk (java development kit) to compile java programs. jre only use to run compiled java programs. in your case its point to a jre and thats why you are getting this.
you can download the jdk and install.
you can download jdk rpm from here
http://www.oracle.com/technetwork/java/javase/downloads/jdk7u9-downloads-1859576.html
use this to choose java alternative if you have already installed.
/usr/sbin/alternatives --config java
Uninstall the installed JRE. Keep only one JAVA defined by JAVA_HOME and define your lib and classpath with respect to JAVA_HOME.

Categories

Resources