How to disable JVM large page support


Area: hotspot/gc
Synopsis: Crashes due to failure to allocate large pages.

On Linux, failures when allocating large pages can lead to crashes. When running JDK 7u51 or later versions, the issue can be recognized in two ways:

  • Before the crash happens one or more lines similar to this will have been printed to the log:os::commit_memory(0x00000006b1600000, 352321536, 2097152, 0) failed;
    error='Cannot allocate memory' (errno=12); Cannot allocate large pages, falling back to regular pages
  • If a hs_err file is generated it will contain a line similar to this:Large page allocation failures have occurred 3 times

The problem can be avoided by running with large page support turned off, for example by passing the "-XX:-UseLargePages" option to the java binary.

If you cannot set this on your command line, you can set this value to JAVA_TOOL_OPTIONS environment variable: export JAVA_TOOL_OPTIONS=”-XX:-UseLargePages”


A good post discussing JVM cannot allocate memory (errno=12)

To enable over-commit temporarily:

echo 1 > /proc/sys/vm/overcommit_memory

For a more permeant solution, you will need to edit /etc/sysctl.conf and add the following:

vm.overcommit_memory = 1

Now just restart your system for the change to take effect.

Create scheduled task in Spring Boot



<project xmlns=”; xmlns:xsi=”;






package com.sample;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

* Created by vagrant on 5/25/17.
public class ScheduledTasks {

private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);

private static final SimpleDateFormat dateFormat = new SimpleDateFormat(“HH:mm:ss”);

@Scheduled(fixedRate = 5000)
public void reportCurrentTime() {“The time is now {}”, dateFormat.format(new Date()));

package com.sample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

* Hello world!
public class App
public static void main( String[] args )

To run: mvn spring-boot:run

a script to install basic Java dev tools for Vagrant provision

#! /bin/bash
echo install jdk1.8
wget –no-cookies –no-check-certificate –header “Cookie: oraclelicense=accept-securebackup-cookie” “;
yum localinstall jdk-8u131-linux-x64.rpm -y
touch /etc/profile.d/
cat <<EOT >> /etc/profile.d/
export JAVA_HOME=”/usr/java/jdk1.8.0_131″
rm jdk-8u131-linux-x64.rpm

echo install ant
tar xvfz apache-ant-1.10.1-bin.tar.gz -C /opt
ln -s /opt/apache-ant-1.10.1 /opt/ant
sh -c ‘echo ANT_HOME=/opt/ant>>/etc/environment’
ln -s /opt/ant/bin/ant /usr/bin/ant
rm apache-ant-1.10.1-bin.tar.gz

echo install python3.6
yum -y groupinstall development
yum -y install
yum -y install python36u python36u-pip python36u-devel
# yum -y install python36u-pip
# yum -y install python36u-devel

echo install Ansible
yum -y install ansible

echo set basic vim style
touch /etc/vimrc
cat <<EOT >> /etc/vimrc
filetype plugin indent on
set tabstop=2
set shiftwidth=2
set expandtab
set softtabstop=2
set nowrap
set number
color blue

echo install maven
tar xvf apache-maven-3.5.0-bin.tar.gz -C /usr/local
rm apache-maven-3.5.0-bin.tar.gz
ln -s /usr/local/apache-maven-3.5.0/ /usr/local/maven
touch /etc/profile.d/
cat <<EOT >> /etc/profile.d/
#! /bin/bash

export M2_HOME=/usr/local/maven
export PATH=$PATH:/usr/local/maven/bin

su -l vagrant -c “mkdir /home/vagrant/.m2”
touch /home/vagrant/.m2/settings.xml
cat <<EOT >> /home/vagrant/.m2/settings.xml

chown vagrant /home/vagrant/.m2/settings.xml

echo install SDKMAN
yum install -y zip unzip
su -l vagrant -c ‘curl -s “; | bash’
su -l vagrant -c ‘source /home/vagrant/.sdkman/bin/’

echo install Spring Boot
su -l vagrant -c ‘sdk install springboot’

echo install Intellij
sudo yum install -y xauth libXtst
tar xvf ideaIC-2017.1.3.tar.gz
mv idea-IC-171.4424.56 /usr/lib
ln -sf /usr/lib/idea-IC-171.4424.56 /usr/lib/idea
ln -sf /usr/lib/idea/bin/ /usr/bin/idea
sed -i ‘s/Xm\(s\|x\)[[:digit:]]*m/Xmx\12048m/g’ /usr/lib/idea/bin/idea.vmoptions /usr/lib/idea/bin/idea64.vmoptions
sed -i ‘s/ReservedCodeCacheSize=[[:digit:]]*m/ReservedCodeCacheSize=700m/g’ /usr/lib/idea/bin/idea.vmoptions /usr/lib/idea/bin/idea64.vmoptions
sed -i ‘4i -XX:MaxPermSize=512m’ /usr/lib/idea/bin/idea.vmoptions /usr/lib/idea/bin/idea64.vmoptions
cat <<EOT >> /etc
sysctl -p

Sample java application to test using headless selenium server


public class App 
    private static void googleExampleThatSearchesFor(final String searchString) throws MalformedURLException {
        WebDriver driver =
                new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),;
        WebElement searchField = driver.findElement("q"));
        System.out.println("Page title is: " + driver.getTitle());

        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver driverObject) {
                return driverObject.getTitle().toLowerCase().startsWith(searchString.toLowerCase());

        System.out.println("Page title is: " + driver.getTitle());

    public static void main( String[] args ) throws Exception{

How to install JDK8 or JDK9 on Ubuntu


  • sudo add-apt-repository ppa:webupd8team/java
  • sudo apt-get update
  • sudo apt-get install oracle-java8-installer
  • sudo update-alternatives –config java



Silent install Oracle JDK 8 on Ubuntu

Problem: During installation of Oracle JDK 8 on Ubuntu, we need to agree on license agreement manually.

Solution: Installing Java Automatically (With Silent Option)

Shell script:

sudo apt-get install -y python-software-properties debconf-utils
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer


- name: Add apt repository
      repo: 'ppa:webupd8team/java'
      state: present
      update_cache: yes

- name: Accept license
    name: 'oracle-java8-installer'
    question: 'shared/accepted-oracle-license-v1-1'
    value: 'true'
    vtype: 'select'

- name: Install java
  apt: name={{ item }} state=present
      - oracle-java8-installer
      - ca-certificates
      - oracle-java8-set-default

One to One mapping in hibernate

<hibernate-mapping package=”gar.entity”>

<class name=”RTPRequest” table=”rtp_request”>
<id name=”id” type=”long”>
<column name=”id” />
<generator class=”sequence”>
<param name=”sequence”>seq_rtp_request</param>
<param name=”allocationSize”>1</param>
<param name=”initialValue”>1</param>

<one-to-one name=”garnishment” class=”Garnishment” cascade=”all”></one-to-one>





<hibernate-mapping package=”gar.entity”>

<class name=”Garnishment” table=”garnishment”>

<id name=”id” type=”long”>
<column name=”id”/>
<generator class=”foreign”>
<param name=”property”>rtpRequest</param>

<one-to-one name=”rtpRequest” class=”RTPRequest” constrained=”true”></one-to-one>