I have installed Drools in my machine and we have m2 repository in our linux machine. Does that mean maven installed in my machine.
If type mvn -v its saying command not found.
I am new to this maven. Kindly help me out
Drools is a library. It does not "install". You add it as a dependency to a Java project. If you "installed" something, it's not Drools. Perhaps it's jBPM or some other application which uses Drools.
Maven is a toolchain. When you install it, the zip file includes a binary that you need to put on your path. That binary (mvn) allows you to run from the commandline.
The two are not related in any way.
If you get an error when trying to run mvn -v that the command is not recognized, that means that the Maven binary is not on your path. Find where you installed Maven, locate the 'bin' directory in that installation, and add that bin directory to your Path environment variable.
If you did not install Maven, and therefore don't have an install directory, you probably want to go do that. Don't forget to put the bin directory on your path after installing.
(A less common way of using Maven involves packaging a mvn.cmd or mvn.sh script with your project itself so that you don't need to have Maven installed globally. If this is what you're doing instead, you need to run the mvn command from the same directory as that script.)
I am using IntelliJ 2020.2.4 version on mac Catalina having JDK 1.8_127. I also installed(unzipped) maven in a folder on my PC. I can get return of the version as maven 3.6.3 when I query mvn -version from mac terminal. This is the good part.
Now went in to the IntelliJ terminal and queried mvn -version, I get zsh: command not found: mvn. BTW, while typing the mvn -version command, the command is highlighted in yellow, plus a green text popup in the bottom of the terminal.
I configured in the preferences under Maven, Maven home directory as (tried) both the bundled Maven (3) and the maven I unzipped in some folder on my mac. Both did not work.
Another weird thing
-(I) is when ever I restart the IDE (only then), I see maven tab on the right hand side vertical edge by clicking which we normally run maven life cycle commands like clean, install, verify etc., Once I click on it, it simply vanishes, until I restart the IDE.
-(II)When I try maven -version can return the correct version of maven as 3.6.3 from the unzipped installation. But when I open another mac terminal, the same command returns the message in the title above. What gives ?
Is this some thing permissions issue on Mac ?
How can I either
(1) use the unzipped maven binary on my mac which is version 3.6.3 inside IntelliJ (OR)
(2) use the bundled maven with IntelliJ by default.
(a) When I go to the location of this bundled maven location like /Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/maven3/bin and invoke mvn -version I get the same result as above.
I get to ask the following:
(a) Why the bundled Maven is not working either inside IntelliJ or
directly invoked from terminal
-(b) Why the external zipped install of
Maven could not be utilized inside the IntelliJ
Seems like this in an Mac OS specific problem. This is what solved it for me:
Open a terminal and make the following:
> vim ~/.zshrc
a
export M2_HOME=/Applications/apache-maven-3.x.x
export PATH=$PATH:$M2_Home/bin/
ESC
:wq
> mvn -version
Where "/Applications/apache-maven-3.x.x" is the path and version of your downloaded und unzipped maven binary of course.
Hope this solves it for other Mac users as well.
I am using javadoc doclets with gradle, so I need to use the package tools.jar, which is in the lib folder from the jdk (1.6.0_26 in my case).
The point is that gradle does not take it automatically, so I was adding that tools package to my libs folder, and then adding it to dependencies.gradle .
Now I want to take it directly from my JDK home into my dependencies.gradle. Is there a way to do that? I have tried the next in my dependencies.gradle:
compile files("${System.properties['java.home']}/lib/tools.jar")
But it does not find it while compiling.
I had this problem when I was trying to run commands through CLI.
It was a problem with system looking at the JRE folder i.e.
D:\Program Files\Java\jre8\bin. If we look in there, there is no Tools.jar, hence the error.
You need to find where the JDK is, in my case: D:\Program Files\Java\jdk1.8.0_11, and if you look in the lib directory, you will see Tools.jar.
What I did I created a new environment variable JAVA_HOME:
And then you need to edit your PATH variable to include JAVA_HOME, i.e. %JAVA_HOME%/bin;
Re-open command prompt and should run.
Found it. System property 'java.home' is not JAVA_HOME environment variable. JAVA_HOME points to the JDK, while java.home points to the JRE. See that page for more info.
Soo... My problem was that my startpoint was the jre folder (C:\jdk1.6.0_26\jre) and not the jdk folder (C:\jdk1.6.0_26) as I thought(tools.jar is on the C:\jdk1.6.0_26\lib folder ). The compile line in dependencies.gradle should be:
compile files("${System.properties['java.home']}/../lib/tools.jar")
I got the same error using Eclipse trying to execute a Gradle Task. Every time I run a command (i.e. war) the process threw an exception like:
Could not find tools.jar. Please check that C:\Program Files\Java\Jre8" is a valid JDK install.
I tried the solution listed in this post but none of them solved this issue. Here my solution :
Go to the "Gradle Task" view
Right Click on the task you want to execute
Select Open Gradle Run Configuration
In the tab "Java Home" select your local JDK repository then click OK
Run again, Enjoy!
I just added a gradle.properties file with the following content:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_45
I had a similar case using Ubuntu. The machine had only the JRE installed. So, I just executed the command below to install the JDK.
sudo apt install openjdk-8-jdk
In macOS Big Sur
The issue happens because of the environment variable JAVA_HOME is not correctly set in macOS Big Sur.
Step 1 - Confirm that you have issue with JAVA_HOME by printing its value in the terminal. You will most likely get an empty string.
echo $JAVA_HOME
Step 2 - Find the correct path on your machine
/usr/libexec/java_home -V
Copy that path associated with "Java SE 8" which usually looks like /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 3 - Edit .zshenv using nano
nano ~/.zshenv
Step 4 - Add the path from step 2 to the file as follows
export JAVA_HOME=YOUR_JAVA_PATH
example:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 5 - Source the updated .zshenv file to activate the environment variable
source ~/.zshenv
Step 6 - Print to confirm the path
echo $JAVA_HOME
I was struggling as well for this Solution. Found a better way to it with Gradle as described here.
We can get the JVM/JDK information from Gradle itself.
dependencies {
runtime files(org.gradle.internal.jvm.Jvm.current().toolsJar)
}
So simple.
In CentOS7 the development package will install tools.jar. The file is not present in java-1.8.0-openjdk
sudo yum install java-1.8.0-openjdk-devel
Add this to gradle.properties:
org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_91
My solution on Mac:
add this line to gradle.properties:
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
not this one:
org.gradle.java.home=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
you can open the last home directory and will find that there is no lib/tools.jar file existence, so change the path to JavaVirtualMachines/jdk1.8.0_271.jdk and it works for me.
By the way, in the terminal, I echo the $JAVA_HOME and it gets the first path, not the second one, I think this is why my Gradle cannot work properly.
With Centos 7, I have found that only JDK has tools.jar, while JRE has not. I have installed the Java 8 JRE(yum install java-1.8.0-openjdk), but not the JDK(yum install java-1.8.0-openjdk-devel).
Installing the latter solves the problem. Also, remember to set JAVA_HOME.
It may be two years too late, but I ran into the same problem recently and this is the solution I ended up with after finding this post:
import javax.tools.ToolProvider
dependencies {
compile (
files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()),
...
}
}
It should work if java.home points to a directory that's not under the JDK directory and even on Mac OS where you'd have classes.jar instead of tools.jar.
On windows 10, I encounter the same problem and this how I fixed the issue;
Access Advance System Settings>Environment Variables>System
Variables
Select PATH overwrite the default
C:\ProgramData\Oracle\Java\javapath
With your own jdk installation that is JAVA_HOME=C:\Program Files\Java\jdk1.8.0_162
On my system (Win 10, JRE 1.8.0, Android Studio 3.1.2, Gradle 4.1) there is no tools.jar in the JRE directory (C:\Program Files\Java\jre1.8.0_171).
However, I found it in C:\Program Files\Android\Android Studio\jre\lib and tried setting JAVA_HOME=C:\Program Files\Android\Android Studio\jre
That works (for me)!
What solved it for me was the following:
found tools.jar in C:\Program Files\Android\Android Studio\jre\lib
copy paste to C:\Program Files (x86)\Java\jre1.8.0_271\lib
ran the code again and it worked.
If you use terminal to build and you have this error you can point to jdk bundled with android studio in your gradle.properties file:
org.gradle.java.home=/usr/local/android-studio/jre
Linux
Open /etc/environment in any text editor like nano or gedit and add the following line:
JAVA_HOME="/usr/lib/jvm/open-jdk"
Windows
Start the System Control Panel applet (Start - Settings - Control
Panel - System).
Select the Advanced tab.
Click the Environment
Variables button.
Under System Variables, click add button, then past the following lines:
in Variable Name : JAVA_HOME
in Variable Value : C:\Program Files\Java\jdk1.x.x_xxx
where x.x_xxx jdk version you can get your jdk version from here C:\Program Files\Java
Under System Variables, select Path, then click Edit,then click new button then past the following line:
%JAVA_HOME%/bin;
This worked for me:
I was getting message
Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_121 contains a valid JDK installation.
In Android Studio, check your SDK Location.
File, Project Structure, SDK Location, JDK Location.
Example: C:\android-studio\android-studio\jre
Copy the tools.jar file in the C:\android-studio\android-studio\jre\lib folder into the C:\Program Files\Java\jre1.8.0_121\lib folder.
Retry.
Like other answers I set org.gradle.java.home property in gradle.properties file. But path with \ separators did not work (building on windows 10):
Java home supplied via 'org.gradle.java.home' is invalid. Invalid
directory: C:Program FilesJavajdk1.8.0_65
So instead of
org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_65
i had to use
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_65
then the build was successful
Problem is that project is build with JRE instead of JDK and since I was building it from eclipse this also worked:
In Window>Preferences>Gradle>Arguments specify Workspace JRE and specify your JDK.
In Window>Preferences>Java>InstalledJREs specify your JDK as default
In my case (Windows 10) after Java update I lost my Enviroment Variables, so I fixed added the variables again, based in the following steps https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
I solved problem on this way:
download file tools-1.8.0.jar on http://www.java2s.com/Code/Jar/t/Downloadtools180jar.htm
unzip file and rename to tools.jar
copy to C:\Program Files\Java\jre1.8.0_191\lib folder
Retry
Put in gradle.properties file the following code line:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_45
Example image
Use this with modern versions of gradle:
def compiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(java.sourceCompatibility.majorVersion) }.get()
implementation compiler.metadata.installationPath.files('lib/tools.jar')
Did you make sure that tools.jar made it on the compile class path? Maybe the path is incorrect.
task debug << {
configurations.compile.each { println it }
}
Adding JDK path through JAVA_HOME tab in "Open Gradle Run Configuration" will solve the problem.
Could not find tools.jar
MacOS
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
And restart Shell
I've tried most of the top options but it seems that I had something wrong with my environment setup so they didn't help. What solved the issue for me was to re-install jdk1.8.0_201 and jre1.8.0_201 and this solved the error for me. Hope that helps someone.
For me this error ocurred after trying to use audioplayers flutter library.
To solve i got tools.jar of the folder:
C:\Program Files\Android\Android Studio\jre\lib
and pasted on
C:\Program Files\Java\jre1.8.0_181\lib.
After this the build worked fine.
My Android Studio Version: 4.2.1
The "tools.jar" is provided by Oracle JDK which is required by android studio for compilation - I have faced this issue after updating android studio to latest version in my PC.
To Resolve the issue follow below steps:
In Android studio File -> Project Structure -> SDKs (Under Platform Settings)
A) Add JDK path by pressing '+' symbol in middle pane if suppose JDK/JDK home path is not present in the middle pane already (Middle pane also contains the Downloaded Android SDK's)
B) Java sdk will be usually present/installed in the path 64 bit => "C:\Program Files\Java\jdk1.X.Y_ABC" (In my PC it is 1.8.0_202) or 32 bit => "C:\Program Files (x86)\Java\jdk1.X.Y_ABC"
If suppose you don't have JDK installed in your PC,
please download and install from Oracle Java website
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
Set JDK and JRE Path(Download both from webpage mentioned in step 2) in system environment variable
A) Press windows key type "Edit the system environment variables" and open the application
B) Go to Advanced -> Environment Variables Under system variables add JAVA_HOME and JRE_HOME as below
Set Windows system environment variable
Add jdk lib path on the Path environment variable under user variables (this step is required only if the error not resolves with the previous steps)
C:\Program Files\Java\jdk1.X.Y_ABC\lib
For Windows add JDK home path to the Gradle property file as org.gradle.java.home.
If you don't have gradle.properties file then create a new one and add
Ex: org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_241
I recently installed the springsource tool suite plugin for eclipse, running on windows 7. But when I open a command prompt (by typing cmd in the windows start menu) and type in:
mvn --version
I get the following response:
'mvn' is not recognized as an internal or external command, operable program, or batch file.
So I then downloaded the stand-alone version of springsource tool suite, which is not what I want. And nonetheless, I still get the same response on the command line when I type in mvn --version. Can anyone tell me how to fix this problem?
I get the same response when I type in java -version . So this might be a command prompt problem. I a following the exact syntax from web tutorials.
EDIT:
I just tried to download m2e in the eclipse marketplace, but got the message that there is nothing new to install. This seems to indicate that I have maven installed, so then how do I access it via the command line in windows 7?
You have to configure your Maven environment variable to be able to use it in the command prompt.
In your case there's no need to download the maven binars because it comes with STS, just find the Maven folder inside the STS directory.
"___" is not recognized as an internal or external command
is shown when program is not installed or the path of that program is not set (to execute from other path).
remember, in "STS", maven is not configured to work out of STS (and terminal usage is out of STS usage).
we have to install it.
maven download link is here
download latest maven from here
extract it where ever you want.
i extracted as below (see the bin,boot,conf,... folders are shown below as in the image):
as this maven download is extracted from zip file (it is not setup), you will have to add this extracted path to "PATH" variable in windows environment.
follow this to set environment path:
now "mvn" command must work.
but
in my case i had to restart STS (spring tool suit) for this to work
I have downloaded Apache-Maven-3.0.4 in zip format and extracted to a directory called My Documents\Software.I have set Path variable to point to the Maven\bin directory.Now when I am checking from command prompt mvn command is working only inside Maven\bin directory.
I want to use Maven with eclipse.Do I have to download eclipse m2e plugin separately or can I make use of the already installed Maven-3.0.4. If I install eclipse m2e plugin where can I find installed m2e plugin ?
In which directory should I put my project to mvn package command to work?
This may sound silly,but I am new to Maven.Please help.
Go to window->preference->maven->installation.
click on Add. Here, you can specify external maven installation, rather internal.
But you need to install m2e plug-in for this.
are you using my eclipse or simple eclipse???
there is an option when u right click on project to add maven capabilities
look at this tutorial...find configure option on right click
link
Regards
Anshul Katta