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 need help to extract WLS, I tried to install WebLogic Server with CMD and i already setup java_home.
But i've got the following error:
Extracting the installer . . . . . . Done
This installer must be executed using a Java Development Kit (JDK)
but C:\Program Files\Java\jre7 is not a valid JDK Java Home.
The log is located here: C:\Users\E440\AppData\Local\Temp\OraInstall2016-12-18_05-38-26AM\launcher2016-12-18_05-38-26AM.log.
Press Enter to exit
I trying to set JAVA_HOME
C:\Oracle\FMW>set java_home
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
And that is the path that i set in environmet variable, but it still display the same error.
I change the command to specified the oracle home
C:\Oracle\FMW>java -jar fmw_12.2.1.2.0_wls_quick.jar oracle_home=C:\app\user\product\11.2.0\dbhome
But again the error is still the same.
The C:\Program Files\Java\jre7 path is not even in my environment variable.
Is there something I missed?
I had the same issue and found this way around:
1- Copied the installer to the JDK folder you want to use for the installation.
In my case: C:\Program Files\Java\jdk1.8.0_121\bin
(Just to make it easier to get to it from the command line latter)
2- Open cmd and navigate until the Java JDK folder
3- Then execute the installer using the java in that folder:
./java -jar fmw_12.2.1.3.0_wls.jar
Here is an image of what I did.
(Dont forget to remove the fmw_12.2.1.3.0_wls.jar from there after the installation is completed)
As I say, is just a way around if you just want to go over the issue and get Weblogic installed. Im sure there are more elegant solutions, but I hope this one helps ;-)
Set up the the path too (in addition to java_home), so the JDK comes before the JRE:
set path=C:\Program Files\Java\<JAVA_VERSION>\bin;%path%
Remember to change the <JAVA_VERSION> to your JAVA version.
eg:
set path=C:\Program Files\Java\jdk1.8.0_202\bin;%path%
I ran a command where java in command prompt and it showed me that the java was installed here:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
I deleted this from the environment variables under path in windows.
while i am running
java -jar fmw_12.1.3.0.0_soa_quickstart.jar
I am executing this command from where my JDK is installed.
Error Message : This installer must be executed using java development kit (JDK)
but C;/program filed /jre is not a valid JDK.
Kindly help.
Oracle Fusion Middleware 12c (12.1.3) requires a minimum of JDK 7.0 Update 55 or later. If you have an older version please update the JDK.
Let’s say your JDK is installed in:
C:\Program Files\Java\jdk1.7.0_xx
Search for cmd.exe in the Start menu. Right-click the cmd.exe and select Run as Administrator. In the prompt run the following command to set the JAVA_HOME:
SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0_xx"
Using the command prompt, navigate to the directory where you unzipped the jar files.
Launch the installation wizard with the appropriate command.
%JAVA_HOME%/bin/java.exe -jar fmw_12.1.3.0.0_soa_quickstart.jar
For details about the installation refer to the official oracle documentation here
Install jdk8. Set JAVA_HOME to the installed jdk8. Navigate to %JAVA_HOME\bin.
Run java -jar complete_path_of_dir\fmw_12.1.3.0.0_soa_quickstart.jar.
Did you check that you're unpacking a jar file which contains another jar file? Firstly, unzip the jar file and then execute the contained jar file.
open your command prompt in admininstrative mode and change your directory to the bin directory of jdk(must be this path- C:\Program Files\Java\jdk\bin).
Now from this directory, install the soa installer(.jar file) by giving its complete path. In my case, I had my soa installer in *E:* drive, so my command was like this:-
C:\Program Files\Java\jdk1.8.0_131\bin>java -jar E:\fmw_12.2.1.0.0_soa_quickstart.jar
in a simple way go to jdk bin folder and execute the following, shoot this command from my jdk\bin location:-
C:/Program Files\Java\jdk1.8.0_131\bin>java -jar d:\fmw_12.2.1.0.0_soa_quickstart.jar
note: make sure you logged in as a admin user
Even I faced the same issue when installing oracle fusion middleware, but i resolved it by following steps:
Open command prompt by right clicking 'Run as administrator'.
Install the latest JDK version.
Change the directory where your weblogic's .jar file is present like
cd C:\Users\Ashwini_SP\Documents\Softwares\Jdeveloper_OSB\fmw_12.2.1.2.0_soaqs_Disk1_1of2
now select the jdk path and install it
"C:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -jar fmw_12.2.1.2.0_soa_quickstart.jar
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