install Jstack on centos - java

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.

Related

Eclipse not recognizing Apache Tomcat on Debian/Linux

I am trying to get an eclipse project to recognize the apache/tomcat(v8.0..) that I have installed, but I am having trouble. The installation is from sudo apt-get install tomcat8, which after a lot of errors I have finally managed to solve. Now I am getting the following after I hook up the tomcat install at /usr/share/tomcat8 to a new project in eclipse.
Description Resource Path Location Type
The container 'Apache Tomcat v8.0 [Apache Tomcat v8.0]' references non existing library '/usr/share/tomcat8/lib/commons-dbcp.jar' helloworld2 Build path Build Path Problem
I'm not sure what the problem could be. There should be no unreferenced libraries as I have installed everything from sudo. I DID have to use this ln -s conf /usr/share/tomcat8/conf to get Eclipse to hook up the library in the first place (as suggested here: Unknown version of Tomcat was specified 8.0.24 / Eclipse 4.4.2 (Luna)). So perhaps that broke it. The road to hello world continues.....
EDIT:
I tried the following:
patientplatypus#next /usr/share/tomcat8/lib $ sudo chmod u+x commons-dbcp.jar
chmod: cannot operate on dangling symlink 'commons-dbcp.jar'
So this appears to be another tomcat8 issue. On installation tomcat8 somehow makes a directory with dangling symlinks to important files. Why it does this or what the fix is, I do not know.
I've not much linux experience, but I use tomcat and eclipse. Eclipse is a mix of java and platform specific binaries, but tomcat is java only (apart from tomcat native which is optional).
If your eclipse supports tomcat8 (I don't remember which version luna supports), you do not need (or even desire) a full server install of tomcat8, you just need to have tomcat package unzipped in any directory you choose, and just point to it.
Which is not the same as installing tomcat8 on your machine and then trying to make it work with eclipse.
My advice is:
Download tomcat8 and unpackage it on a folder.
Create a server runtime with eclipse pointing to that folder.
Develop.
Once you have a war to deploy, you can install tomcat8 on a machine and put your war there and use it.

Installing the Java JDK on Windows 10 and Cygwin without admin permissions

I'm trying to install the Java JDK on Windows 10 and under the Unix-style Cygwin system. I don't have admin rights though. This limits install of both Cygwin and Java JDK.
(Existing solutions here only cover JDK without admin rights).
Update:
I've found a way to do this, described in this helpful article: Installing the Java JDK on Windows 10 without admin rights. Basically, you can install Cygwin without admin rights using "--no-admin", and then extract the JDK install executable to install manually, the JDK paths can then be setup. And Java compiler (javac) ran.
you can download zip file of jdk from below link:
https://java.com/en/download/manual.jsp#win
After that set JAVA_HOME and PATH. It will work!!

Copying OpenJDK folder present at /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.38.x86_64 from one system to another

I installed OpenJDK 6 on CentOS 6.7 VM using "yum install java-1.6.0-openjdk-devel". This created a folder /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.38.x86_64/. Can i zip this folder, copy it to another machine and use java present in this folder on that machine? Are there any symbolic links that are created when i do yum install which will be missed when i zip the folder?
Purpose: I am writing a program which will download specified JDK version and start another java process with this JDK. All my machines where this program will be used have the same OS (CentOS 6.7).
Why not working with Yum Cache?
The following command returns the path to rpms:
find /var/cache/yum -iname '*.rpm' –
The rpm cache directory location can be found in /etc/yum.conf
cachedir=/var/cache/yum/$basearch/$releasever
You should change the $basearch and $releasever, values based on your red hat release version.
If you want to keep the rpm cache after installation the keep cache value should be set 1 in:
/etc/yum.conf
set
keepcache=1

Get Oracle Java 1.8 in windows without installing it

Is it possible to get Java in zip format? I don't want to install it by getting .exe file.
Is there any zip version of Java 1.8 so that I can download it and extract it and start using it in my Windows machine (64-bit processor)?
You can extract the JDK folder from the Installation EXE.
Check this link for the steps. The post was for JDK 1.7 it will work for JDK 1.8 also
Do the following.
Steps
Download JDK from Oracle
Download and Install 7-zip from here
Open installition exe using 7-Zip
Extract the tools.zip
Extract the content of tools.zip to a folder (e.g. c:\jdk).
Open the extracted folder in cmd prompt.
Execute for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar" command
Set JAVA_HOME to the jdk (e.g c:\jdk) folder.
Add %JAVA_HOME%/bin to the PATH env variable.
Testing
Run the following command to check the installation, it will print the version of JDK.
c:> javac -version
javac 1.7.0_51
NOTE: Tested with JDK 1.7 and 1.8
Update 1
Edited the answer to add the steps in the answer itself instead of the link to a blog post.
Update 2
For 64-Bit please check unpack-jdk-x64.bat by grabantot
I was looking for a solution to this as well. I'm not sure why the OP wanted to do this. I'm just trying to get a newer version of java for new development while not interfering with an older Java install which a legacy application requires (I'd like to update the legacy app, but it's not an option, now)
I think the hack I am going to try is this:
Install 1.8
Take a copy of the install folder
Uninstall 1.8
Reinstall / Repair 1.7
restore the copy of 1.
I'm sure if I had a better understanding of what the install is doing, this would not be necessary.
I had a spare virtual machine hanging around (if not you could build one or maybe even download one) so I:
installed the Oracle JDK in the guest
copied the jdk folder from the guest to the host
added a JAVA_HOME environment variable.
The operating systems obviously have to be close (not sure how close, I used Windows Server 2008 64 bit guest on a Windows 10 64 bit host and it seemed to work).
Was a quick fix for me as I didn't want a full install and wanted to remove it afterwards.
If you do not have permission to unzip zip file then you cannot install java .
As java does not need installation for running . You just need to give path of java.exe where it is located .
In Windows it is located in C:\Program Files\Java\jdk1.8.0_05\bin
For a solution you can run installer on any machine that you have permission and just copy and paste the folder of java to anywhere in your system (Machine where you have administrative rights problem) . and just set the path as by opening command prompt as set path="C:\Program Files\Java\jdk1.8.0_05\bin"
java will be working as you want
The following worked for me (I had JDK 1.8 installed and needed the 32 bit version as well):
Verify the current version with java -version
Assuming a different version (minor or major is being installed), download the relevant JDK installable from Oracle and run it. In the
first dialog, specify a different folder than the default location
(might work with the default one as well), then select Next. It will
extract the files there in this folder, then it will asl for the
folder where the JRE is to be installed. Simply close the installer,
now you should have just the JDK in the specified folder.
Rerun java -version, it should give you the same version as earlier.
Worst case, if it shows the newer version, go to your system path (Right click My Computer (or This PC) -> Properties -> Advanced
system settings -> Advanced tab -> click on Environment variables
button) and remove the Oracle javapath entry (From the Path variable
in the bottom part of the window). The add the older java version's
bin folder to the path variable in the beginning.
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
Is this working for linux shell scripting , I got syntax error for the above.

Installing Java Runtime with Saltstack

I'm using Salt to configure a bunch of Centos machines (rpm-based) and I need to install the Java runtime. I've seen some discussion of doing this with Ubuntu-based machines but I wonder if anybody has done it on Redhat-based distros. The problem is getting past the "accept license" dialog without user intervention.
You can actually pre-seed the answers to those interactive questions. Here's a thread from the salt-users mailing list showing how: https://groups.google.com/d/msg/salt-users/95Q707FFWYo/CdcJN7FPpRAJ
There is this nice saltstack-formula/sun-java-formula
Formula to set up and configure Java JREs and JDKs from a tarball archive sourced via URL.
It can be installed using formulas documentation. I did not test this on a centos installation, but it uses tarball installation so maybe it would work. If someone tests it on a rvm based system, please comment here! ;)
I successfuly installed this on a debian machine with the following pillar:
java_home: /usr/lib/java
java:
source_url: http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jre-7u79-linux-x64.tar.gz
jce_url: http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip
version_name: jdk1.7.0_79
prefix: /usr/share/java
dl_opts: -b oraclelicense=accept-securebackup-cookie -L
It installed java-jdk successfully, but it failed to install jce. I created issue #20 for this just in case, but I don't actually need jce (at least, not now).

Categories

Resources