Where is tools.jar located? - java

Running CentOS 6, Java 1.7.0_25 OpenJDK
Upon installing the RPM I saw it say
Unpacking JAR files...
rt.jar
jsee.jar
charsets.jar
>tools.jar
Where is tools.jar located? I checked /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64
No where to be found.

Not sure what rpm you used, but if you install from yum repo, you should install java-1.7.0-openjdk-devel in addition to java-1.7.0-openjdk.
Then you will find tools.jar in /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.xx.x86_64/lib directory.

On Linux, you can use locate tools.jar to find where the file is.
Typically, it should be in the lib/ directory of your jvm. On Ubuntu/Debian, it is located in directory /usr/lib/jvm/java-xxxxx/lib/tools.jar.
For example, with openjdk 7, on amd64, I'll find it under /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar.
I have no installation to check it, but I think that the directory structure is the same under CentOS (cf. https://serverfault.com/questions/50883/what-is-the-value-of-java-home-for-centos)

Linux Centos 6,
you can use sudo find / -name "tools.jar" command to find the file location.
tools.jar is normally located under /usr/lib/jvm/java-1.7.0.70.x86_64/lib/tools.jar
tools.jar is not in JRE.
My case, tools.jar file is generated only after installing java-1.7.0-openjdk-devel.
sudo yum install java-1.7.0-openjdk-devel

On windows, I could find it at \jdk1.7.0\lib. You can find java directory structure here

No,it should be in in Lib folder
JDK and JRE File Structure
c:\jdkx.x.x\lib
Files used by the development tools. These include tools.jar, which contains non-core classes for support of the tools and utilities in the JDK. Also includes dt.jar, the DesignTime archive of BeanInfo files that tell interactive development environments (IDE's) how to display the Java components and how to let the developer customize them for an application.

Related

install Jstack on centos

my centos Server is running the Spring boot application. I am trying to take threaddump of java process. But I cannot find jstack utility on the server. I figured out someone just installed the jre and did not install jdk, that may be the reason why jstack is missing.
Can you please let me know how can I install jstack on this server?
is there any pre-install checks ? or does it involve any downtime ?
You can have several java installations on the same OS by using jdk install from tar file option.
You may manually install jdk to a single parent directory by making use of the .tar.gz jdk installation option.
This option will enable you to download a the .tar.gz file into a new directory, then untar the downloaded file and answer some license agreement.
you will see the you will find jstack in the bin directory in the directory the of the jdk you have just installed. You may need to use the full file path of this jstack file when using.

jlink packages current platform's binaries

I am trying to build cross-platform archives of an application built using Java 11 and packaged with jlink.
For the cross-platform packaging I am basing my build on this answer. I have managed to make my Gradle build download the target platform's JDK and invoke jlink with the appropriate jmods folder, however the target image always includes the binaries and JRE structure of the host platform (in my case Windows, meaning the generated bin folder always includes DLLs and Windows executables). If I supply the --strip-native-commands flag then no executables are included at all, although the DLLs still are.
Is there any way to make jlink package the correct JRE files?
Host JDK: Windows Oracle JDK 11.0.10 x64
Target JDK: OpenJDK 11.0.2 x64
Sample Linux invocation:
C:\Program Files\Java\jdk-11.0.10/bin/jlink.exe
--module-path C:\projectdir\build\install\project-linux\lib;C:\projectdir\build\JREs\linux\jmods
--add-modules com.acme.app
--compress 2
--launcher app=com.acme.app/com.acme.app.Main
--no-header-files
--no-man-pages
--strip-debug
--dedup-legal-notices=error-if-not-same-content
--output C:\projectdir\build\packageFiles\linux
GraalVM
Using GraalVM CE Java 11 21.0.0 yields:
java.io.IOException: Invalid JMOD file: C:\jdks\graalvm-ce-java11-21.0.0\jmods\java.base.jmod
Which makes it seem like GraalVM's jlink always attempts to use the host's JMOD files.
OpenJDK
Using OpenJDK 11.0.2 x64 yields the same result of including the host's binary files in the created runtime image. The same behaviour is true for Zulu OpenJDK 11.0.10+9 x64.
Found the issue: the problem was with my reference to the jmods directory of both the Linux and the MacOS JDK distributions.
For the Linux one I mistakenly setup the build to download version 11.0.1 instead of 11.0.2, which ended up leading to the logic to flatten the hierarchy not flattening it. This means that the build/JREs/linux/jmods reference wasn't targeting any existing folder, meaning that jlink doesn't find the JDK modules there hence the host files being included.
The MacOS JDK has a completely different file structure so the flattening logic was just wrong. Ultimately this lead to the same missing jmods folder symptom.
With both issues fixed the jlink tool now correctly packages the target JDK's files when building cross-platform runtime images.

How can I get JAVA 9 JRE / JDK as a zip file rather than EXE or MSI installer?

How can I get JAVA 9 JRE / JDK as a zip file rather than EXE or MSI installer?
https://jdk9.java.net/download/
Look at https://jdk9.java.net/ carefully there's "JDK 9 Early Access with Project Jigsaw" that is actually zip download.
You can download JDK 9 zip file from Java Platform, Standard Edition 9 Reference Implementations
As mentionend you can download the jigsaw distribution or you can follow the instructions from here to build your own distribution.
From here: https://stackoverflow.com/a/6571736/8714033
Create working JDK directory (C:\JDK in this case)
[Download][1] latest version of JDK from Oracle (for example jdk-7u7-windows-x64.exe)
[Download][2] and install 7-Zip (or download [7-Zip portable][3] version if you are not administrator)
With 7-Zip extract all the files from jdk-XuXX-windows-x64.exe into the directory C:\JDK
Execute the following commands in cmd.exe:
cd C:\JDK\.rsrc\1033\JAVA_CAB10
extrac32 111
Unpack C:\JDK\.rsrc\1033\JAVA_CAB10\tools.zip with 7-zip
Execute the following commands in cmd.exe:
cd C:\JDK\.rsrc\1033\JAVA_CAB10\tools\
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar" (this will convert all .pack files into .jar files)
Copy all contents of C:\JDK\.rsrc\1033\JAVA_CAB10\tools where you want your JDK to be
Setup JAVA_HOME and PATH manually to point to your JDK dir and its BIN subdirectory.
Though my experience was a bit different, tools.zip can be in a different place depending on JDK version.
You can download JDK 9 Early-Access Builds from jdk.java.net, All other locations (jdk9-builds, jdk9.java.net) are not accessible/migrated.

ant -version results in missing tools.jar file error [duplicate]

I am building a project in Java.
I have this error:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
I have installed a JDK and the folder: C:\Program Files\Java\jre6\lib is in my system but the file tools.jar is not there.
Yes, you've downloaded and installed the Java Runtime Environment (JRE) instead of the Java Development Kit (JDK). The latter has the tools.jar, java.exe, javac.exe, etc.
In case this is still an issue for anyone, I have a bit of clarification on the previous answers. I was running into this same issue using ant with only a JDK installed. Although, the JDK installer gave me a directory structure like this:
Directory of C:\Program Files\Java
05/08/2012 09:43 AM <DIR> .
05/08/2012 09:43 AM <DIR> ..
05/08/2012 09:46 AM <DIR> jdk1.7.0_04
05/08/2012 09:19 AM <DIR> jre6
05/08/2012 09:44 AM <DIR> jre7
0 File(s) 0 bytes
and when I ran ant, it complained about not finding tools.jar under the jre7 subdirectory. It wasn't until I set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_04" that the error went away.
Install the Java SDK.
Add a System Environment Variable called JAVA_HOME with the value of JDK location.
Go to Control Panel\System and Security\System. Advanced System Settings, Environment Variables, System Variables, New... Example:
Variable Name:JAVA_HOME
Variable Value: C:\Program Files\Java\jdk1.7.0_21
Close/reopen your CMD window so that the new variable takes effect before attempting to re-run the ant command.
I had the same problem and copying C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext worked for me
If you have installed JDK 9.0.1 you will also have this problem as the tools.jar has been deprecated. See migration document.
Set your JAVA_HOME environmental variable to point to C:\Program Files\Java\jdk1.7.0_02.
If you are in Linux you can solve this by installing java on the system:
sudo apt-get install openjdk-7-jdk openjdk-7-jre
No, according to your directory structure, you have installed a JRE, not a JDK. There's a difference.
C:\Program Files\Java\jre6\lib
^^^^
It should be something like:
C:\Program Files\Java\jdk1.6.0_24
Don't spend too much time looking for tools.jar. If you get an error like that, don't be upset.
If you already have java JDK 1.5, go to your lib folder, and the tools.jar should be available there. Copy and paste it in your ant bin folder, then try to use the command ant -version.
You should see the expected result.
I had the same issue on a linux machine. I was quite frustrated at first, because I have installed both the JDK and JRE. I am using version 1.6, 1.7 and 1.8 simultaneously, and I have played a lot with the alternatives to have everything set properly.
The problem was quite stupid to solve, yet counter-intuitive. While I was using the correct JDK, I paid attention to the path of the tools jar maven complained about - it was expecting it to be
$JAVA_HOME\..\lib\tools.jar
The $JAVA_HOME variable pointed directly to my jdk folder (/usr/local/java which was also the correct $PATH entry and alternative sym link). It actually searches for the lib folder outside the java directory, because:
$JAVA_HOME\..\lib\tools.jar
will resolve to
/usr/local/lib/tools.jar
and that is not a valid location.
To solve this, the $JAVA_HOME variable should instead point to this location /usr/local/java/jre (assuming the JDK path is /usr/local/java) -- there is actually jre folder inside the JDK installation directory, that comes with each JDK. This new setup will cause maven to look at the JRE directory, that is part of the JDK:
$JAVA_HOME\..\lib\tools
which now resolves to
/usr/local/java/jre/../lib/tools.jar
and finally to
/usr/local/java/lib/tools.jar
which is where the tools.jar really resides.
So, even if you are indeed using the JDK instead of the JRE, the $JAVA_HOME has to point to the JRE. Remember, the OS alternative should still refer to the JDK.
go to your jdk path where you installed your java
For e.g In my PC JDK installed in the following path
"C:\Program Files\Java\jdk1.7.0_17\";
After go to the lib folder e.g "C:\Program Files\Java\jdk1.7.0_17\lib"
in the lib directory there is tool.jar file
Copy this file and past it in the lib forlder of jre7 directory
for e.g
"C:\Program Files\Java\jre7\lib"
You may face similar problem on Ubuntu:
Embedded error: tools.jar not found: /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
The problem is with JAVA_HOME that is not set properly.
So, on Ubuntu 14.04 x64 using Java8:
sudo apt-get install openjdk-8-jdk openjdk-8-jre
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
As many people mentioned, it looks like you are looking in your JRE instead of the JDK for the tools.jar file.
I would also like to mention that on recent versions of the JDK, there is no more tools.jar file. I downloaded the most recent JDK as of today (JDK version 12) and I could not find any tools.jar. I had to download JDK version 8 (1.8.0) here https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to get the tools.jar file. I downloaded that version, took the tools.jar file and put it into my recent version's lib folder.
It's worth observing that tools.jar has been removed from the JDK since Java 9. https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-055EA9F4-835E-463F-B9E1-9081B3D9E55D
If people are facing this issue compiling a Java program with JDK 9+, you may need to review the dependencies of your projects.
In my case, I was trying to compile a project using AspectJ and the Maven plugin org.codehaus.mojo:aspectj-maven-plugin:1.11. After searching online, I found an alternative that supports Java 9+: dev.aspectj:aspectj-maven-plugin:1.13.M3.
I had the same problem even after installing Java JDK and set JAVA_HOME to ..\jdk1.6.0_45\bin folder.
Ant is still trying to find tools.jar in C:\Program Files\Java\jre6\lib folder.
I've fixed it by adding JAVACMD environment variable and set path for it to java.exe in the jdk folder.
In my case it was C:\Program Files\Java\jdk1.6.0_45\bin\java.exe
it has been solved with me in windows os by setting the JAVA_HOME variable before running as follows:
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
Make sure that both the %JAVA_HOME% and %JAVA_HOME%/bin paths are added to your PATH variable.
All the answers about copying tools.jar into the correct position is a poor idea at best.
Make sure that your IDE can find these jars the way it was designed and intended for.
In eclipse window> preferences>Java> Installed JRE, I pointed the directory to the jre directory in the jdk 1.7 and i worked file for me
e.g C:\Program Files\Java\jdk1.7.0_71\jre
I had my JDK_path (C:\Program Files\Java\jdk1.7.0_79) in my JAVA_HOME and also the JDK_path\bin in my PATH. But, still my ant was using the JRE instead of JDK.
The issue was I had C:\ProgramData\Oracle\Java\javapathbefore my JDK_path in PATH variable. I simply moved my JDK_path before the oracle one and the issue solved.
solving this problem I have simply copied the tools.jar file from C:\Program Files\Java\jre1.8.0_112\lib to C:\Program Files\Java\jdk1.8.0_112\lib so that I have two tools.jar files instead of one and problem disappeared.
Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
if you have installed jdk then
..Java/jdkx.x.x
folder must exist there so in stall it and give full path like
C:\Program Files\Java\jdk1.6.0\lib\tools.jar
Make sure that your classpath is set correctly and pointing to the correct version of the JDK that you have installed. Also, are you using Open JDK? I have had this issue before after I tried to move from open JDK to Suns JDK. This is an example of how that issue could be fixed.
maven-compiler-plugin use jdk ,not jre,
tools.jar is in C:\Program Files\Java\jdk1.6.0\lib\tools.jar
you must config project JRE System Libary with jdk,not jar. This is the simplest solution.
Right click on your ant file
Go to "Run as" then click on "Ant Build..."
Go to the "JRE" tab
Select a JDK and not a JRE
For me what's working: I downloaded an old version of Java 1.7
I actually set my JAVA_HOME from C:/program files X86/Java BUT after I installed the 1.7 version I had another Java in program files/Java. And at this moment I found the tools.jar here. Then I changed for this new path and it's working
I was also facing the same error.
This was removed after setting Java_Home path to C:\Program Files\Java\jdk1.8.0_121.
Please ensure bin is not included in the path and no slash is there after jdk1.8.0_121 after you have defined %JAVA_HOME%\bin in the system path variable.
If you're in a RHEL environment the package name containing tools.jar would end with "openjdk-devel".
This is the solution for Windows: in Computer > Advanced system settings > Advanced > Environment variables..., add this in System variables:
I have downloaded tools.jar and after that I copied it into path in error message.
C:\Program Files\Java\jdk-11.0.1\bin > paste here tools.jar
After that I have restarted Spring Tool Suit 4 and everything was working.
When I was trying to fix that problem I have made new environmental variable:
Control Panel / System / Advenced / Environmental variables / new
Name : JAVA_HOME
Value: C:\Program Files\Java\jdk-11.0.1
But I do not know is it necessary.
maybe you have updated the JREs in the OS, and the addition has added in the "path" of the environment variables an entry ".../Oracle/jer" that overwrites your JAVA_HOME.
try to remove it from the "path" by leaving JAVA_HOME.

Typesafe activator: Java JDK not installed or can't be found

I am trying to run the typesafe activator on Windows7 (32bit).I have JDK 1.8 installed. It keeps saying I don't have a valid JDK installation:
A Java JDK is not installed or can't be found.
Please go to
http://www.oracle.com/technetwork/java/javase/downloads/index.html
and download a valid Java JDK and install before running Activator.
If you think this message is in error, please check
your environment variables to see if "java.exe" and "javac.exe" are
available via JAVA_HOME or PATH.
I had a similar problem on Windows 7 64b. The problem solved by changing the installed directory from "C:\Program Program..." to a directory without space like "c:\java".
So the solution is: Installing Java to a path without spaces.
I hope it can help.
Put the Activator Directory (not the Java Directory) where it's path does not contain spaces! (ie C:\Program Files\ ... is NOT valid)
Also place the Java PATH before all other paths in your Environment Variables.

Categories

Resources