OpenJDK JDK11 not having JMC- Java Mission Controller- FlightRecorder - java

I was hoping JMC would be available with OpenJDK, JDK11 binaries as this has been opensourced from Java 11 by oracle, but could not locate this in Oracle and AdoptOpenJDK Java-11 binaries under bin folder.
I have also tried this https://jdk.java.net/jmc/ as some article said its being releases separately.
Does anyone know how to get JMC for OpenJDK-11.

I am editing this answer since builds are now available, and have been available, from multiple vendors for quite some time. The list is available in the readme for the JMC GitHub repo:
https://github.com/openjdk/jmc
Don't forget to give the project a star if you like it! :)
Here is the original answer:
Normally the builds will be available here:
https://jdk.java.net/jmc/
See http://hirt.se/blog/?p=1007 for more information on the new delivery format.
The builds have been (temporarily) pulled because a switch from the old javax.mail coordinates to the new coordinates at jakarta-ee has not yet gotten the proper third-party approval. A new build, with plenty of fixes and with all the approvals properly in place (or a revert of the change), should be along within the next few weeks.
Up until then it is possible (also not hard) to build JMC 7, by pulling the official JMC repo from here:
https://hg.openjdk.java.net/jmc/jmc7/
You can also build and pull the mainline mirror from the inofficial GitHub repo:
https://github.com/JDKMissionControl/jmc
For more information on building JMC, see:
http://hirt.se/blog/?p=947 (or simply read the README.md in the repository root)
Good luck!

Since Java11, JMC is not part of the JDK any more. It is a separate project, as you already noticed.
https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html

Azul provides free, unsupported builds of Zulu Mission Control available for download at http://azul.com/products/zulu-mission-control
Builds are available for clients running Windows, Linux, and Mac OS X.
There are now binaries produced by Oracle as well:
https://jdk.java.net/jmc/

I believe they're still evaluating GitHub to moving to an independent repository with current progress being still under jmc7.
You can currently download standalone versions from Oracle's website for mission-control.

BellSoft provides Liberica Mission Control: https://bell-sw.com/pages/lmc/
As per their documentation, it's free to use in production environments, and there is a commercial support included as part of Support Subscription for Liberica JDK.

Update
JMC 8 available when compiling it from source. Here is a single command for linux users to build your own copy of jmc
mkdir ~/jmcToDelete && \
cd ~/jmcToDelete && \
git clone https://github.com/openjdk/jmc.git && \
cd jmc/releng/third-party && \
mvn p2:site && \
runJetty="mvn jetty:run" && \
bash -c "$runJetty &" && \
cd ~/jmcToDelete/jmc/core && \
mvn clean install && \
cd ~/jmcToDelete/jmc && \
mvn package -Dmaven.test.skip=true && \
kill $(jps | grep Launcher | awk '{print $1}') && \
sudo mkdir -p /opt/java/jmc && \
sudo tar xzf $(find ~/jmcToDelete/jmc/target -name '*.jmc-linux*') -C /opt/java/jmc && \
sudo ln -s /opt/java/jmc/jmc /usr/local/bin/jmc && \
rm -rf ~/jmcToDelete
typing jmc in a terminal should start it.
Outdated
As stated by Hirt you can compile it from http://hg.openjdk.java.net/jmc
The jmc available in jdk8 (v5.5) requires the special flags -XX:+UnlockCommercialFeatures -XX:+FlightRecorder to be present in the JVM process and it will not retrieve "flight records" if they are not there, so you can only use it with java1.8. If you would like to add those flags on openjdk-11 it will fail with Unrecognized VM option 'UnlockCommercialFeatures' meaning that you don't need them as they are enabled by default ( FlightRecorder ).
I compiled jmc-7.1.0 without issues by downloading the gz archive from http://hg.openjdk.java.net/jmc/jmc/
Follow the steps present in the README file:
Make sure the compilation is done with jdk1.8
In one terminal :
cd releng/third-party
mvn p2:site
mvn jetty:run
And in the second terminal:
cd core
mvn clean install
cd ..
mvn package
On completion you should have all your artefacts in the target folder.
The default jmc start script has a lot of flags present and it will not start with all of them, hence you can start the intended jar using
java -jar ./jmc-[...]/target/products/jmc/plugins/org.eclipse.equinox.launcher_[...].jar

Related

How to run JCMD without JDK on a docker container with openJDK installed

I need to run JCMD on prod to monitor my application, but unfortunately I can't have a proper JDK in place so I need to run it with a JRE. I can add some dependencies, but not the whole jdk.
I'm using openJDK 8.
Does anyone know how to do it?
There was one question already posted here (How to run jcmd without the JDK?), but the answer works for windows servers, not for linux OS in a docker container.
In my personal experience jcmd from newer version of Java works with the older versions.
You can exploit the multi-stage build feature and have jlink elegantly package for you the (strictly) necessary files, please refer to this Dockerfile:
FROM adoptopenjdk:11-jdk-hotspot
RUN ${JAVA_HOME}/bin/jlink --module-path jmods --add-modules jdk.jcmd --output /jcmd
FROM adoptopenjdk:8-jre-hotspot
COPY --from=0 /jcmd /jcmd
In case you prefer, I give you "an" answer for Java 8, using adoptopenjdk and multistage build
FROM adoptopenjdk:8-jdk-hotspot
RUN mkdir -p /jcmd && \
mkdir -p /jcmd/bin && \
mkdir -p /jcmd/lib && \
cp ${JAVA_HOME}/bin/jcmd /jcmd/bin/jcmd && \
cp -r ${JAVA_HOME}/lib/* /jcmd/lib
FROM adoptopenjdk:8-jre-hotspot
COPY --from=0 /jcmd ${JAVA_HOME}
in this case jcmd gets installed along the jre installation, in the same bin folder as java.
I tested both of them in both docker-desktop 20.10.7 and Mirantis (Docker Enterprise) 3.3.11.

Error updating tzdata 2018f (Released 2018-10-18) with tzupdater-2.2.0

I'm trying to update JVM's Time Zone info using TZUpdater 2.2.0.
> [root#local tzupdater-2.2.0]# java -jar tzupdater.jar -V
tzupdater version 2.2.0-b01
JRE tzdata version: tzdata2018d
tzupdater tool would update with tzdata version: tzdata2018f
So, I'm running the command below:
> [root#local tzupdater-2.2.0]# java -jar tzupdater.jar -l
However, I'm getting this error message:
Failed: java.lang.Exception: Failed while parsing file '/tmp/tz.tmp_1/asia' on line 1655 'Rule Japan 1948 1951 - Sep Sat>=8 25:000S'
java.lang.Exception: Failed while parsing file '/tmp/tz.tmp_1/asia' on line 1655 'Rule Japan 1948 1951 - Sep Sat>=8 25:00 0 S'
at tools.tzdb.TzdbZoneRulesCompiler.parseFile(TzdbZoneRulesCompiler.java:377)
at tools.tzdb.TzdbZoneRulesCompiler.compile(TzdbZoneRulesCompiler.java:191)
at tools.tzdb.TzdbZoneRulesCompiler.<init>(TzdbZoneRulesCompiler.java:307)
at com.sun.tools.tzupdater.ExternalModule.compileToJSRBinary(ExternalModule.java:153)
at com.sun.tools.tzupdater.TimezoneUpdater.run(TimezoneUpdater.java:230)
at com.sun.tools.tzupdater.TimezoneUpdater.main(TimezoneUpdater.java:634)
Caused by: tools.tzdb.DateTimeException: Invalid value for SecondOfDay value: 90000
at tools.tzdb.ChronoField.checkValidValue(ChronoField.java:173)
at tools.tzdb.LocalTime.ofSecondOfDay(LocalTime.java:210)
at tools.tzdb.TzdbZoneRulesCompiler.parseMonthDayTime(TzdbZoneRulesCompiler.java:475)
at tools.tzdb.TzdbZoneRulesCompiler.parseRuleLine(TzdbZoneRulesCompiler.java:399)
at tools.tzdb.TzdbZoneRulesCompiler.parseFile(TzdbZoneRulesCompiler.java:354)
... 5 more
I'm using https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz as the source for the tzdata bundle.
Edited - In addition, I'm using either Java(TM) SE Runtime Environment (build 1.8.0_66-b17) and OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1~deb9u1-b13), meanwhile I have same reported problem using TZUpdater or ZIUpdater
Can anyone help me about this issue? Any comment will be appreciated.
Many thanks.
Yes, the rules for Japan in 1948-1951 changed in 2018f in an "interesting" way: officially, Japan's fall back occurred at 25:00 on Saturday, instead of 01:00 on the Sunday. That confused the Java time zone updater, as well as my own Noda Time project.
There's now a commit to avoid 25:00 in the "rearguard" format - the rearguard format is basically more conservative, avoiding things like Ireland's negative DST.
I would expect a 2018g release at some point reasonably soon, to include that fix. Assuming the tzupdater tool uses the rearguard appropriately, I'd expect that to sort things out. If you can possibly wait until then, I'd do so. Otherwise, use the -l flag on tzupdater to specify a different data source, e.g. for 2018e: https://data.iana.org/time-zones/releases/tzdata2018e.tar.gz
If you need to use version 2018f but not the Asia timezone you can use it from 2018e and the other files from 2018f.
I've created the file tzdata2018f-01.tar.gz in my repository https://github.com/lucasbasquerotto/my-projects/tree/master/tz for anyone that wants to avoid making these manual changes.
There is an example of using ziupdater when creating a docker image with OpenJDK, but if you use Oracle JDK you should be able to use almost the same code to use tzupdater changing
java -jar /app/tmp/ziupdater-1.0.1.2.jar -l file:///app/tmp/tzdata2018f-01.tar.gz
to
java -jar /app/tmp/tzupdater.jar -l file:///app/tmp/tzdata2018f-01.tar.gz
or even
java -jar tzupdater.jar -l https://github.com/lucasbasquerotto/my-projects/raw/master/tz/tzdata2018f-01.tar.gz
if you don't want to download it manually.
In the example in my repository it generates a Docker image, but you can use it without docker, with Java installed directly in your OS.
I executed the last example above on my local machine (that uses Oracle JDK) and the timezone was corrected successfully:
public static void main(String[] args) {
System.out.println("Date: " + new Date()); // prints correctly now
}
Just make sure that you aren't using some third-party library (like Joda Time) that uses timezone data hardcoded in its own jar (or generate a jar from the source with updated timezone data, like in https://www.joda.org/joda-time/tz_update.html).
Since tzdata2018g is already released with the fix provided in rearguard format, please use the rearguard tzdata bundle with -l option.
For tzdata2018g the command will look like this:
java -jar tzupdater.jar -l https://web.cs.ucla.edu/~eggert/tz/release/2018g/tzdata2018g-rearguard.tar.gz
Had the same issue here, and the problem seems to be just on the latest version.
Using
java -jar tzupdater.jar -l https://data.iana.org/time-zones/releases/tzdata2018d.tar.gz
(if "2018d" is enough for you) should work fine.
For some reason, after that, upgrading to the latest tzdata also worked fine (with just a warning).
I was running into the same error, then I fixed the downloaded file from IANA, using the following shell script, which replaces the troublesome line in the file by the previous version of "asia" file, as described by #lucas-basquerotto in his post below. I've tested and it works fine!
Please, download the TZUpdater bundle, extract the tzupdater.jar and update the variable TZUPDATER_JAR with the full file path of the downloaded jar file in order to run the script successfully.
#!/bin/bash
#FULL PATH TO tzupdater.jar
TZUPDATER_JAR='/home/user/tzupdater.jar'
OUTPUT_ALL=$(java -jar $TZUPDATER_JAR -l 2>&1 >/dev/null)
echo "$OUTPUT_ALL" | grep -e "Caused by: tools.tzdb.DateTimeException: Invalid value for SecondOfDay value: 90000" > /dev/null
if [ $? -eq 0 ]
then
FIXME_FILE=$(echo "$OUTPUT_ALL" | grep -Po "(?<=java.lang.Exception: Failed while parsing file ').+(?=' on line 1655 'Rul)")
echo "file $FIXME_FILE contains a syntax error"
ERROR_LINE=$(sed -n '1656,1656p' $FIXME_FILE )
echo "Line 1655 \"$ERROR_LINE\" contains an error"
FIXED_LINE=${ERROR_LINE/Sat>=8/Sun>=9}
FIXED_LINE=${FIXED_LINE/25:00/0:00}
echo "Line 1655 fixed: \"$FIXED_LINE\" ( rule \"Sat>=8 25:00\" replaced by \"Sun>=9 0:00\" as it was used to be on previous version )"
sed -i "s/$ERROR_LINE/$FIXED_LINE/" $FIXME_FILE
TEMP_DIR_NAME=$(dirname $FIXME_FILE)
cd $TEMP_DIR_NAME
mkdir tzdata
mv tzdata.tar.gz tzdata/
cd tzdata/
echo "untar original tzdata.tar.gz"
tar -xf tzdata.tar.gz
rm tzdata.tar.gz
FIXME_FILENAME=$(basename $FIXME_FILE)
echo "replacing original $FIXME_FILENAME file"
rm $FIXME_FILENAME
cp ../$FIXME_FILENAME $FIXME_FILENAME
echo "building a new tar ball with the fixing"
tar -czf ../tzdata-updated.tar.gz *
echo "installing the updated tar file (requires elevation sudo)"
sudo java -jar $TZUPDATER_JAR -l "file:///$TEMP_DIR_NAME/tzdata-updated.tar.gz"
if [ $? -ne 0 ]
then
echo "something went wrong!"
exit 2
fi
fi
echo "installation successful!"
Save this is script under the name update_jdk_tzdata.sh and grant it permission to execute: chmod +x update_jdk_tzdata.sh and execute it ./update_jdk_tzdata.sh (it requires sudo in order to update JRE files)
Update your version of Java 8; the tzupdater tool just works in Java 8 update 181.
Use these commands:
sudo apt-get install oracle-java8-installer
sudo update-alternatives --config java
and choose the number *0 (automatic)
sudo update-alternatives --config javac
and choose the same *0.
If you already have the tzupdater only see the version of it that is already 2018
java -jar tzupdater.jar -V
If you are having problems with the Japanese version, you can use another link for Brazil.
java -jar tzupdater.jar -l https://data.iana.org/time-zones/releases/tzdata2018e.tar.gz

Installing JDK on Linux

I’m trying to install JDK on Centos, but I’m getting an error:
[root#www opt]# rpm -ivh /opt/jdk-7u51-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
error: unpacking of archive failed on file /usr/java/jdk1.7.0_51/db/lib/derbyLocale_zh_CN.jar;533ab42a: cpio: read
Where can be problem?
Thanks
Can you please check the md5sum of the downloaded file against these values here: http://www.oracle.com/technetwork/java/javase/downloads/java-se-binaries-checksum-1956892.html ?
If the md5sum does not check, it must be a broken download.
A short answer: try downloading and installing again.
A longer answer:
Even though you are getting this, the jdk is getting installed. Sort of. This seems to be an error in the packaging but it is not fatal. Here is the output from my machine. In the example I cat'd the release file so you can see what CentOS I'm using and did an md5sum on the rpm I'm using. You'll notice that it doesn't match the md5sum from the Oracle site link (provided above by Kristof).
Next, I did an ls on the target directory for the jdk /usr/java/ so you can see that it is empty. Then ran the rpm install and did another ls to show that some files are there.
Of course, this defeats the purpose of using rpm, because the install information is not going to go into the rpm database. If I query the database it doesn't come up and it's missing the links that usually get installed pointing to 'latest' and 'default'
So I took a guess that maybe there is a mirror that might have a bad rpm and went to the Oracle site and downloaded the file again. I gave it a different name so that I can compare the two files. This time it was successful.
In the screen shot below you can see the two files. The newest download being the one I called jdk-7u51-linux-x86_64.rpm. You can see the md5sum shows the files are different, but on the new file, the md5 matches the Oracle site. I removed the directory that was created by the failed install and then ran the rpm -ivh command and it completed successfully. The ls on the /usr/java directory shows all the correct stuff and querying the rpm database shows it was installed. Hope this helps!
You can do it with simple script which you can find here
It's for Centos rpm, but you can edit script and change rpm to tar.gz for example
Also you can change version or env in variables bellow
BASE_URL="technetwork/java/javase/downloads"
BASE_URL_OUTPUT="$(curl -s -L0 http://www.oracle.com/${BASE_URL}/)"
JAVA_ENVIRONMENT="JDK"
JAVA_BASE_VERSION=8
DOWNLOAD_SITE="$(echo $BASE_URL_OUTPUT | grep -m 1 -io "${JAVA_ENVIRONMENT}${JAVA_BASE_VERSION}-downloads-[0-9]*.html" -- | tail -1)"
echo "DOWNLOAD_SITE="$DOWNLOAD_SITE
DOWNLOAD_LINK_OUTPUT="$(curl -s -L -j -H "Cookie: oraclelicense=accept-securebackup-cookie" http://www.oracle.com/${BASE_URL}/${DOWNLOAD_SITE} | grep -io "filepath.*${JAVA_ENVIRONMENT}-[${JAVA_BASE_VERSION}].*linux[-_]x64[._].*\(rpm\)" -- | cut -d '"' -f 3 | tail -1)"
echo "DOWNLOAD_LINK_OUTPUT="$DOWNLOAD_LINK_OUTPUT
curl -L -o java_rpm_packet.rpm -b "oraclelicense=a" $DOWNLOAD_LINK_OUTPUT
and install with
yum localinstall -y java_rpm_packet.rpm

How to compile JavaMail Mbox Store on Linux?

I need to store locally emails downloaded via POP3 and so I'm tring to use JavaMail Mbox Store, which is part of the JavaMail source code but not compiled.
https://java.net/projects/javamail/pages/MboxStore
I've followed the instructions at the end of this page, but with no luck. Here comes what the instructions says:
export MACH=`uname -p`
export JAVA_HOME=/usr/java
cd mbox
mvn
cd native
mvn
I've changed the JAVA_HOME variable according to my environment. I get no error until the last command. The docs says that by default these are the options used by maven:
mvn -Dcompiler.name=c89 \
-Dcompiler.start.options='-Xa -xO2 -v -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/solaris' \
-Dlinker.name=c89 \
-Dlinker.start.options='-G' \
-Dlinker.end.options='-L${env.JAVA_HOME}/jre/lib/${env.MACH} -lmail -ljava -lc'
I've changed the compiler name to gcc and removed some options unrecognized by gcc (-Xa and -x02). Unfortunately, it complains about a missing maillock.h.
Do you know where I can find a complete list of dependencies? Am I doing something wrong with options? I've tried to look for any pre-compiled version, but I had no luck.
I'm trying to compile on Slackware 14.1.
On Ubuntu/Debian/Mint you need the liblockfile-dev package.
To build on Debian Whezzy I had to manually set the archecture and then add the -shared option to stop the undefined reference to main (asumming the linux equivalent to -G in Solaris). Also add the additional library path for linjvm which is under the server directory
export MACH=amd64
mvn -Dcompiler.name=c89 \
-Dcompiler.start.options='-v -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/linux' \
-Dlinker.name=c89 \
-Dlinker.start.options='-shared' \
-Dlinker.end.options='-L${env.JAVA_HOME}/jre/lib/${env.MACH} -L${env.JAVA_HOME}/jre/lib/${env.MACH}/server -llockfile -ljava -jverify -ljvm -lc'

Installing java using chef

I know how to install java on linux machine using terminal. But i want to automate the installation using Chef Framework. I have two machines M1 and M2. I am on machine M1 and want to install java on machine M2. This is what i do in using terminal....
first i SSH into machine M2, after i do the following things... (in here i download the java files from third party storage.)
Step1:-
cd setup
step2:-
wget http://downloads.company.com/downloads/DevTools/jdk/6.0/jdk-6u31-linux-i586.bin
Step3:-
chmod +x jdk-6u31-linux-i586.bin
Step4:-
yes | ./jdk-6u31-linux-i586.bin
Step5:-
cd /usr/bin
Step6:-
mv java javaorg
Step7:-
cd /usr
Step8:-
ln -s /home/harish/setup/jdk1.6.0_31 java
Step9:-
echo 'export PATH=$PATH:/usr/java/bin' > /etc/profile.d/alljava.sh;echo 'export JAVA_BINDIR=/usr/java/bin' >> /etc/profile.d/alljava.sh;echo 'export JAVA_ROOT=/usr/java' >> /etc/profile.d/alljava.sh;echo 'export JAVA_HOME=/usr/java' >> /etc/profile.d/alljava.sh;echo 'export JRE_HOME=/usr/java/jre' >> /etc/profile.d/alljava.sh
Step10:-
source /etc/profile.d/alljava.sh
Step11:-
echo $JAVA_HOME
Step12:-
java -version
I have following questions:
what is the category of the problem (chef-solo or shef-server)
do i need to have machine M2 installed Chef.
i have downloaded the cookbook for JAVA from GitHub but i don't know what to do with that.
i have written some code for installing java on SAME machine.. but it also not working..
CODE:
#cookbook/java/recipe/default.rb
*####This will install JAVA on machine M1######*
execute "copy" do
cwd "/home/user/setup"
command "wget http://downloads.company.com/downloads/DevTools/jdk/6.0/jdk-6u31-linux-i586.bin"
end
execute "change_mode" do
command "chmod +x jdk-6u31-linux-i586.bin"
end
execute "dont_know" do
command "yes | ./jdk-6u31-linux-i586.bin"
end
execute "make link" do
command "ln -s /home/harish/setup/jdk1.6.0_31 java"
end
java_home = "export JAVA_HOME=/usr/java/jdk1.6.0_31"
path = "export PATH=$PATH:JAVA_HOME/bin"
file "/etc/profile" do
content "#{java_home}\n#{path}"
owner "root"
end
but this code is giving some big messages..(errors).
can anybody help through this and also how to use the downloaded cookbooks for JAVA.. thanks. :)
This is a long out-of-date question, but I'll include an answer in case someone stumbles in on this one.
Opscode has a Java cookbook that they maintain that can install either OpenJDK or Oracle JDK. It's available at the opscode community site here.
You can use it by adding a dependency to your cookbook's metadata.rb:
depends "java", "~> 1.10.2"
and including the recipe in your cookbook's default.rb:
include_recipe "java"

Categories

Resources